S
Steve Chermak
I am trying to write code that will run overnight to publish project files to
project server, to the PWA. I have code in an Excel file that runs code to
open project server and publish 3 files. I utilize the Windows Scheduled
Tasks to launch an Autpen subroutine in the Excel file.
When I am logged on to the server and run the macro, the publishing goes ok.
But when this runs overnight, the first file does not publish and gives an
Object required (number 424) error. (The code errors at the set pjProj =
pjApp.ActiveProject command, in my code at the end of this post).
I can not figure out why my being logged on matters or what is missing (when
I am not logged on) for the first one or why after the first one the rest
publish ok.
I put error trapping code in the macro both to try and determine the problem
and also to proceed forward if one file can not be published. This will be
necessary even once I overcome this issue because there may be other reasons
unrelated to code errors why one of the files may not publish correctly and I
do not want the whole effort to stop because of a problem with only one file.
If anybody has any ideas, I would appreciate them. Below is the relevant
part of my code (a subroutine launched 3 times by other code):
*********************************
Public Sub Do_publishing(theEvent As String, theWkbkSN As String, theWkbkLN
As String)
pjWkbkShortName = theWkbkSN
pjWkbkLongName = theWkbkLN
myEvent = theEvent
errNum = 0
errDesc = ""
errSrc = ""
LogComment_withError myEvent, errNum, errDesc, errSrc
' ========= Open File ===============
myEvent = "ERROR Trying to Open File for " & pjWkbkLongName
On Error GoTo line01
pjApp.FileOpenEx Name:=pjWkbkLongName, _
ReadOnly:="False", _
NoAuto:=True, _
FormatID:=""
' ========= Set Variable ===============
myEvent = "ERROR trying to set variable for " & pjWkbkLongName
Set pjProj = pjApp.ActiveProject
' ========= Publish ===============
myEvent = "ERROR Trying to Publish for " & pjWkbkLongName
pjApp.Publish
' ========= Close ===============
myEvent = "ERROR Trying to Close File for " & pjWkbkLongName
pjApp.FileCloseEx Save:=pjSave, CheckIn:=True
' =========== Write to Log File ===========
myEvent = "Published OK"
errNum = 0
errDesc = " "
errSrc = " "
LogComment_withError myEvent, errNum, errDesc, errSrc
Exit Sub
line01:
errNum = Err
errDesc = Err.Description
errSrc = Err.Source
LogComment_withError myEvent, errNum, errDesc, errSrc
End Sub
project server, to the PWA. I have code in an Excel file that runs code to
open project server and publish 3 files. I utilize the Windows Scheduled
Tasks to launch an Autpen subroutine in the Excel file.
When I am logged on to the server and run the macro, the publishing goes ok.
But when this runs overnight, the first file does not publish and gives an
Object required (number 424) error. (The code errors at the set pjProj =
pjApp.ActiveProject command, in my code at the end of this post).
I can not figure out why my being logged on matters or what is missing (when
I am not logged on) for the first one or why after the first one the rest
publish ok.
I put error trapping code in the macro both to try and determine the problem
and also to proceed forward if one file can not be published. This will be
necessary even once I overcome this issue because there may be other reasons
unrelated to code errors why one of the files may not publish correctly and I
do not want the whole effort to stop because of a problem with only one file.
If anybody has any ideas, I would appreciate them. Below is the relevant
part of my code (a subroutine launched 3 times by other code):
*********************************
Public Sub Do_publishing(theEvent As String, theWkbkSN As String, theWkbkLN
As String)
pjWkbkShortName = theWkbkSN
pjWkbkLongName = theWkbkLN
myEvent = theEvent
errNum = 0
errDesc = ""
errSrc = ""
LogComment_withError myEvent, errNum, errDesc, errSrc
' ========= Open File ===============
myEvent = "ERROR Trying to Open File for " & pjWkbkLongName
On Error GoTo line01
pjApp.FileOpenEx Name:=pjWkbkLongName, _
ReadOnly:="False", _
NoAuto:=True, _
FormatID:=""
' ========= Set Variable ===============
myEvent = "ERROR trying to set variable for " & pjWkbkLongName
Set pjProj = pjApp.ActiveProject
' ========= Publish ===============
myEvent = "ERROR Trying to Publish for " & pjWkbkLongName
pjApp.Publish
' ========= Close ===============
myEvent = "ERROR Trying to Close File for " & pjWkbkLongName
pjApp.FileCloseEx Save:=pjSave, CheckIn:=True
' =========== Write to Log File ===========
myEvent = "Published OK"
errNum = 0
errDesc = " "
errSrc = " "
LogComment_withError myEvent, errNum, errDesc, errSrc
Exit Sub
line01:
errNum = Err
errDesc = Err.Description
errSrc = Err.Source
LogComment_withError myEvent, errNum, errDesc, errSrc
End Sub