Saving/restoring a selection

  • Thread starter Conrad Santiago
  • Start date
C

Conrad Santiago

Using MS Project Visual Basic, what is the best approach to save a selection
of tasks? During the life of the macro/form, the selection may change, so I
want to be able to restore the original selection. There are two hurdles I'm
facing so far:

1. Whereas the original selection may include a range containing well over
10 tasks, I cannot seem to restore more than 10 selected tasks.

2. During the life of the macro/form, a task in the original selection may
be deleted. Therefore, whatever method is used to save the original
selection must be flexible enough to delete or ignore the deleted task when I
go to restore the selection.

Any ideas on the most effective approach would be greatly appreciated.
Conrad Santiago
 
J

Jim Aksel

Try creating a Collection Object and placing the items there.
You could also add a property to each item concerning its "deleted" status
--
If this post was helpful, please consider rating it.

Jim

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
R

Rod Gill

Hi,

You will need to create an array of Long numbers to store the Unique ID of
all selected tasks.

To restore I would iterate thru the array and build a new array (same size)
of the latest row numbers (Task ID) for each Unique ID. Sort the array and
make sure the Project is sorted by ID.

Now iterate thru the new array and for each contiguous block of IDs adjust
the selection:

SelectTaskField Row:=0, Column:="Name", Height:=6
SelectTaskField Row:=12, Column:="Name", Height:=1, Add:=True

You will need to calculate the height as the number of contiguous row
numbers

This is do-able, but will require careful thought.

Note that most VBA code does not require you to change the active selection
at all and good practice strongly recommends not doing so unless absolutely
necessary.

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top