changing the view

M

Mark

How can i change the view to Gantt Chart without using a string. So i dont
want to use viewApply ="Gantt Chart"

I noticed that pjGantt exists but i am not sure how this can be used. Any
code provided must be able to work on project 2000.

Many Thanks in advance
 
J

John

Mark said:
How can i change the view to Gantt Chart without using a string. So i dont
want to use viewApply ="Gantt Chart"

I noticed that pjGantt exists but i am not sure how this can be used. Any
code provided must be able to work on project 2000.

Many Thanks in advance

Mark,
What's wrong with the ViewApply Method? It's probably the best and most
convenient way to set a view.

John
Project MVP
 
M

Mark

Because the code needs to be non language dependant. so using strings does
not work in diff languages
 
J

John

Mark said:
Because the code needs to be non language dependant. so using strings does
not work in diff languages

Mark,
Ok, I understand what you are trying to do. There may be a way to use
the view constant directly but after a little searching I couldn't
figure it out. However, not to leave you hanging without any answer,
here is a scheme that is a little clunky but it will work.

Depending on how many languages you need to write code for, you could
use the following code to get the list of available views for each
language.

Sub ViewList()
Dim v As Variant
For Each v In ActiveProject.ViewList
Debug.Print v
Next v
End Sub

Once you have the list or lists, you can then set up a lookup table in
your code for each language. It shouldn't be to difficult to put some
code at the beginning of your procedure to detect which language version
it is being used with. Then use the ViewApply Method and pull the view
string name from the appropriate lookup table.

Sometimes you have to use an indirect method to get what you want. When
I first started writing VBA for Project I often had to resort to
indirect ways of getting what I needed simply because Project's Object
Model didn't have or make certain things available. Newer versions of
Project have added many new objects, but you know, those old VBA macros
with indirect methods still work with the newer versions of Project.

John
Project MVP
 
M

Mark

Unfortunately these all use strings so they are no help to me, because my
customer may be using a diff lang version of project. I did state this in my
original post.
 
J

Jan De Messemaeker

Hi,

Sorry to disagree.
Taskviewlist(1) is Gantt Chart in the English version, "Diagramme de Gantt"
in the French version
The number 1 is not a string AFAIK.
HTH

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
J

John

Jan De Messemaeker said:
Hi,

Sorry to disagree.
Taskviewlist(1) is Gantt Chart in the English version, "Diagramme de Gantt"
in the French version
The number 1 is not a string AFAIK.
HTH

Jan,
If I may interject, Mark needs to be able to set a view using language
independent code. Unless there's a trick I'm missing, the ViewList and
TaskViewList properties are read only.

John
Project MVP
 
M

Mark

Found my answer.

I use viewapply with version 2000 and the view object with version 2002 and
above. Its seems Microsoft added the view object when they brought out non
English versions.
 
J

Jan De Messemaeker

Hi John,

Maybe I was a bit short but
ViewApply taskviewlist(1) brings out the Gantt Chart in any language
environment: it is truly language independent
Greetings,
Jan
 
J

John

Mark said:
Found my answer.

I use viewapply with version 2000 and the view object with version 2002 and
above. Its seems Microsoft added the view object when they brought out non
English versions.

Mark,
I'm glad you found a solution that works for you. Sorry we couldn't be
more helpful.

John
 
J

John

Jan De Messemaeker said:
Hi John,

Maybe I was a bit short but
ViewApply taskviewlist(1) brings out the Gantt Chart in any language
environment: it is truly language independent
Greetings,
Jan

Jan,
OK, I'll bite, how do you make that work? I tried it in both Project
2000 (the poster's version) and Project 2003 and in both cases I get a
compile error - sub or function not defined. Obviously I'm missing
something.

John
 
J

John

Jan De Messemaeker said:
Hi,

Was short again, taskviewlist is a project object
Viewapply activeproject.taskviewlist(2)
changes the view to Calendar

HTH
Jan,
Ok, now we're getting someplace. Sometimes a little more info is really
helpful.

I learned something - hopefully I will remember :)
John
 

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