Toggle macro for day / hours viewing

P

Paul/C.

I want to set up a macro in Project to enable me to toggle (using something
like Ctrl-T), the 'Work is entered in' field under Tools>Options>Schedule tab
to switch between hours and days depending on what is currently displayed. ie
if my view is currently in hours, it will change to days and vice versa. I
can create a simple macro for a one way conversion and assign it to a hotkey
but can't get the toggle to work.
 
J

JackD

What code are you using now?
It is easier to start with that than to help you write something new.
 
P

Paul/C.

Recording a simple macro to change from hours to days is a straightforward
OptionsSchedule WorkUnits:=7 and I can assign this to a key and run the
macro and it will change all my ETC, Baseline, Actuals etc from hours to
days. However, I want to be able to change it back again and don't really
want 2 separate macros to do this. So I started along the lines of

If pjHour Then
OptionsSchedule WorkUnits:=7 ' days
ElseIf pjDay Then
OptionsSchedule WorkUnits:=5 ' hours
End If

but this doesn't work and I can't perform the if-then-else on the WorkUnits
because VB doesn't like the space or the ':'.
Hope this helps.
Paul/C.
 
J

JackD

Ok, The problem is that those options are write only (you can't read the
value - only set it).
So use some other value that you can read and write to keep track.

Sub OptSched()
'using projectsummarytask flag field to keep track
If ActiveProject.ProjectSummaryTask.Flag1 Then
OptionsSchedule workunits:=7
ActiveProject.ProjectSummaryTask.Flag1 = False
Else
OptionsSchedule workunits:=5
ActiveProject.ProjectSummaryTask.Flag1 = True
End If
End Sub
 

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