Todor,
In this situation you have a couple of things going on.
First, has MS Project fully loaded? Some things are loaded on demand,
such as
the VBE. And in this case it looks like it hadn't loaded yet.
Second are you marshalling back and forth and back looking for a VBE to
use. In this case
I believe this is what is happening. To prevent you from having to make
your users install and
run a script that just calls DoEvents. Since it's the VBE that's
causing all the marshalling, you just
have to force Project to load it. From the testing I did here the
performance boost is 10 fold.
In the end we just got rid of the marshalling and yes you are right, this
was a COM marshalling issue.
Stephen Culhane
(e-mail address removed)
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
| From: "Todor Todorov" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| Subject: Re: Project Automation too slow
| Date: Wed, 28 Jan 2004 23:38:37 +0100
| Lines: 392
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#
[email protected]>
| Newsgroups: microsoft.public.office.developer.automation
| NNTP-Posting-Host: skansen-50-170.ip-pluggen.com 212.181.50.170
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.office.developer.automation:8281
| X-Tomcat-NG: microsoft.public.office.developer.automation
|
| Stephen,
|
| I use late binding. Automation is per definition late binding.
Initializing
| VBE in project does the trick and the script runs faster
I just don't
| understand what is happening if I don't initialize VBE. I also discovered
| that if I set App.Visible to true I could actually see the tasks being
| slowly created in project. If I then just click on a menu (just to unfold
a
| menu, e.g. the "View" menu), the script speeded up to what I would expect
as
| normal. After that all subsequent calls to Project would run fast. My
guess
| was something with a time-out or something with the way the message pump
| works. That's the reason I tried "DoEvents" to see if I could force
Project
| to "spin" the message pump and process messages and marshalled OLE calls.
I
| don't know why it helps clicking on a menu or calling "DoEvents", but my
| guess is something to do with marshalling of OLE calls.
|
|
| -- Todor
|
|
| | > Todor,
| > The problem is that MS Project is marshalling back and forth to the
VBE
| > environment in Excel, and not
| > using the VBE environment in MS Project. The performance is being lost
in
| > the marshalling. When you
| > instantiate the VBE environment in MS Project you get rid of that
| > marshalling, and get the performance back.
| >
| > I tested the script I sent you in Excel, and due to that suggested
that
| > you run that test in Excel, and include a
| > reference to the MS Project Object Library. As you are using SmallTalk
| and
| > can't include the MS Project Object
| > Library, I recommend using the methods you currently use in SmallTalk to
| > instantiate the MS Project, and test the
| > oApp.VBE.ActiveVBProject.Saved property, which will force the VBE
| > environment MS Project to be loaded. In you
| > situation I can only conclude that you will need to use late binding.
| >
| > Let me know if this describes what was wrong, and why?
| >
| >
| >
| > Stephen Culhane
| > (e-mail address removed)
| > Microsoft Developer Support
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| rights.
| >
| >
| >
| >
| > --------------------
| > | Thread-Topic: Project Automation too slow
| > | thread-index: AcPi4M7r77/tjvaqR4a7LgV28QBDuQ==
| > | X-Tomcat-NG: microsoft.public.office.developer.automation
| > | From: "=?Utf-8?B?VG9kb3IgVG9kb3Jvdg==?=" <
[email protected]>
| > | References: <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > <
[email protected]>
| > | Subject: Re: Project Automation too slow
| > | Date: Sat, 24 Jan 2004 17:16:06 -0800
| > | Lines: 234
| > | Message-ID: <
[email protected]>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.office.developer.automation
| > | Path: cpmsftngxa07.phx.gbl
| > | Xref: cpmsftngxa07.phx.gbl
| > microsoft.public.office.developer.automation:8250
| > | NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| > | X-Tomcat-NG: microsoft.public.office.developer.automation
| > |
| > | Hello Steve,
| >
| > I got it working and the performance is not much mode acceptable. It
takes
| > about 5 to 6 secs. to add 100 tasks including startup of Project. This
is
| > from VBScript (a VBS file).
| >
| > Unfortunately, I can't add reference to MS Project 11 Object Lib,
because
| > the environment I use (Visual Smalltalk Enterprise) uses automation and
| > does not know anything about type libraries. It's much like VBScript.
| >
| > Can you please write two or three lines of what was wrong and why test =
| > oApp.VBE.ActiveVBProject.Saved helped.
| >
| > Thanks
| >
| > -- Todor
| >
| > ----- Steve Culhane [MS] wrote: -----
| >
| > Todor,
| > In reserarched this issue further and have another workaround
that
| > doesn't require
| > a Sub in Project that calls DoEvents. But first here's an
| explanation
| > of
| > what is happening.
| > Apparently VBE has not been initalized, and is slowing down the
| > process.
| > In this sample I
| > call the VBE ActiveProject and check the Saved Property. This
forces
| > VBE
| > to initialize. In
| > my test this version will run in 10 seconds from terminal server
and
| > won't
| > requier that you call
| > DoEvents in a sub hidden in MS Project. One last important note.
In
| > this
| > test code I told Excel
| > that I was using a referance to MSProject. You should do that from
| > the
| > Tools Menu in the VBE
| > editor. Just select the "Referances" Menu Item, and go down to you
| > Microsoft Project Object Library
| > selection. In my case it was the "Microsoft Project 11.0 Object
| > Library."
| >
| > Sub test()
| >
| > Dim oApp As MSProject.Application
| > Dim oProj As MSProject.Project
| > Dim oTasks As Tasks
| > Dim test
| >
| > Set oApp = CreateObject("MSProject.Application")
| > oApp.FileNew
| > ' Here we initialize VBE, and get rid of the bottleneck
| > test = oApp.VBE.ActiveVBProject.Saved
| >
| > Set oProj = oApp.ActiveProject
| > Set oTasks = oProj.Tasks
| > For i = 1 To 100
| > Set otask = oTasks.Add(False)
| > otask.Type = 1
| > otask.Name = "Task " & i
| > otask.Notes = "Nothing to comment here :-/"
| > otask.Text30 = "My Specific Text"
| > Next
| > Set oProj = Nothing
| > Set oTasks = Nothing
| > oApp.FileCloseAll pjDoNotSave
| > oApp.Quit
| > Set oApp = Nothing
| >
| > End Sub
| >
| >
| > Stephen Culhane
| > (e-mail address removed)
| > Microsoft Developer Support
| >
| > This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| >
| >
| >
| >
| > --------------------
| > | Thread-Topic: Project Automation too slow
| > | thread-index: AcPgE3Wpoq1kKR5cSfqTIpcMTQiXaA==
| > | X-Tomcat-NG: microsoft.public.office.developer.automation
| > | From: "=?Utf-8?B?VG9kb3IgVG9kb3Jvdg==?=" <
[email protected]>
| > | References:
| >
|
<
[email protected]><
[email protected]
| >
|
l><
[email protected]><
[email protected].
| > gbl><
[email protected]>
| > | Subject: Re: Project Automation too slow
| > | Date: Wed, 21 Jan 2004 03:41:07 -0800
| > | Lines: 101
| > | Message-ID: <
[email protected]>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.office.developer.automation
| > | Path: cpmsftngxa07.phx.gbl
| > | Xref: cpmsftngxa07.phx.gbl
| > microsoft.public.office.developer.automation:8221
| > | NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| > | X-Tomcat-NG: microsoft.public.office.developer.automation
| > |
| > | I've just tested the VBScript at the server console and it's not
| > much
| > faster. About 75 secs for 100 items.
| >
| > -- Todor
| >
| > ----- Todor Todorov wrote: -----
| >
| > Hello Wei-Dong Xu.
| >
| > 1. The test uses VBScript and automation to add tasks to a new
| > project. The
| > real scenario is a Smalltalk application, but it does the same
| as
| > the
| > VBScript. In other words, the code is not called inside of
| > Project but
| > from
| > outside.
| >
| > 2. I've just restarted the terminal server and disabled some
| > service
| > such as
| > virus scanner etc. The test macro in the mpp file takes less
| than
| > 1
| > sec. The
| > Excel macro takes 11 secs. The VBScript test still takes about
| 65
| > secs.
| >
| > 3. I can't log on at the console at the moment. I'll try
Monday
| > when I
| > am at
| > the office and have physical access to the server.
| >
| > 4. Running the code as admin, but from a terminal server
session
| > uses
| > less
| > than 1 % CPU. Winproj.exe uses 0% or 1% CPU time.
| >
| > 5. I am not sure I can install Project Professional. It's a
| > production
| > server and I have to ask a colleague of mine that is
responsible
| > for
| > it.
| > Another issue is that we only have a Standard license and the
| > MSDN
| > license -
| > and MSDN licenses and production environment don't mix very
| well.
| > Also,
| > Office is for some reason installed in Danish, so must
Project.
| > We've
| > tried
| > to install US project, but it f*cks up the Office
installation -
| > macros do
| > not work any more. So it's not an easy task.
| >
| > Here's something very strange. After some debugging I was able
| to
| > find
| > a
| > pattern. If project was visible and I run the VBScript test
| code,
| > I
| > could
| > see tasks slowly appearing in the Gantt view. It turns out
that
| > if I
| > click
| > on a menu item in MS Project, it completes the VBScript
| > imideately.
| > The same
| > is also true for other items of the UI, e.g. tool buttons.
Then
| I
| > did
| > some
| > more testing and hacking. I made a global method:
| > Sub DoEv()
| > DoEvents
| > End Sub
| >
| > Then I changed my test code to:
| > Set app = CreateObject("MSProject.Application")
| > app.FileNew
| > app.Run "DoEv"
| > Set proj = app.ActiveProject
| > Set tasks = proj.Tasks
| > For i = 1 To 100
| > Set task = tasks.Add(False)
| > task.Type = 1
| > task.Name = "Task " & i
| > task.Notes = "Nothing to comment here :-/"
| > task.Text30 = "My Specific Text"
| > Next
| > It now runs much faster. It completes the code in less than 3
| > secs.
| > That's
| > very acceptable. Is there a way to call DoEvents without
having
| > to add
| > a
| > method (macro) to the project? Also, I don't like hacking the
| > Global
| > project
| > or other things that may result in security issues.
| >
| > -- Todor
| >
| >
| > message
| > | > > Hi Todor,
| > >> Thank you for replying and the regmon log!
| > >> From the log, I found some not found record for the vbaoff
| key
| > which spent
| > > a lot of time during the execution. This is very odd. So far
| as
| > I
| > know,
| > the
| > > vbaoff key is used to disable the Visual basic for
| Application.
| > Then
| > I
| > > design one test for you and it will be greatly appreciated
you
| > tell
| > me
| > more
| > > information regarding this issue. I list them below:
| > >> 1. I'd like to know the detailed senario and reproduce
steps
| > on this
| > > server. Are you using the code in Project macro or in other
| > applictions?
| > > 2. Please use an administrator account and terminate other
| > users
| > session
| > > (only one user on this terminal server). Run the macro
"test"
| > in the
| > > test.mpp. How long it will take?
| > > 3. Log on to the server with a administrator account at
| console
| > and
| > run
| > the
| > > macro "test" from one excel workbook. Does the issue
persist?
| > > 4. When the code is runing, please check the winproj.exe
| > process and
| > let
| > me
| > > know the CPU usage on this process. In addion, please let me
| > know the
| > total
| > > CPU usage at that time on this server.
| > > 5. If convenient, for test pupose, please uninstall Project
| > Standard
| > and
| > > install Project Professional on this server and test it
again.
| > >> I have mailed these test files(test.mpp and test.xls) to
you.
| > These
| > files
| > > are not very small, i have sent one mail for each to you. If
| > you
| > can't
| > > received them, please post this in the newsgroup, I will
| resend
| > them
| > to
| > you
| > > or somewhere you provide (ftp, webdav etc)! Thanks!
| > >> Please feel free to let me know if you have any further
| > questions.
| > >> Does this answer your question? Thank you for using
Microsoft
| > NewsGroup!
| > >> Wei-Dong Xu
| > > Microsoft Product Support Services
| > > Get Secure! -
www.microsoft.com/security
| > > This posting is provided "AS IS" with no warranties, and
| > confers no
| > rights.
| > >
| > |
| >
| >
| > |
| >
|
|
|