VB - Toggling the outline indent

L

Leo

I want to create code that will since the state (True or False) of
"OptionsView DisplayNameIndent" and then change it to the opposite state. I
have created code below. I am having problems with the way I am asking the IF
portion of the code. I know I am not doing it correctly but I cant find
anything that shows me the correct way. Anyone have any ideas?

Sub Outline_toggle()
' Macro Outline_toggle
If DisplayNameIndent Then
OptionsView DisplayNameIndent:=False
Else
OptionsView DisplayNameIndent:=True
End If
End Sub
 
J

JackD

It may be that DisplayNameIndent is a write-only property. That is you can
not read the value you can only write it.
In that case I'd use a flag of some sort to determine the state of indent.

something like this:

Sub Outline_toggle()
' Macro Outline_toggle
If ActiveProject.ProjectSummaryTask.Flag1 = True Then
OptionsView DisplayNameIndent:=False
ActiveProject.ProjectSummaryTask.Flag1 = False
Else
OptionsView DisplayNameIndent:=True
ActiveProject.ProjectSummaryTask.Flag1 = True
End If
End Sub

--
-Jack ... For Microsoft Project information and macro examples visit
http://masamiki.com/project
or http://zo-d.com/blog/index.html

..
 
K

Kevin

Leo,
You cannot use a named argument in an "if" test. DisplayNameIndent" is a
named argument to the OptionsView function. There is no property in the
object model called "DisplayNameIndent", so you can't use it to check the
state of the name indent.

In fact, there is currently no property in the Project object model that
corresponds to the field in the dialog box. Check out the following article
for a list of the fields in the dialog box that DO have properties associated
with them:

http://www.microsoft.com/technet/scriptcenter/topics/office/manage/project/projectvi.mspx

Best you can do is set the value using the OptionsView method, and set some
other variable or custom property to keep track of its state. Good luck!

Kevin
 

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