当我按下F5在Project Server 2013中运行以下宏时,应用程序终止。
但是用F8运行它可以正常工作。发生了什么事?
Sub EditProject()
Dim objXL As Object
Dim objWB As Object
Dim objWS As Object
Dim projApp As MSProject.Application
Dim file_name As String
Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.workbooks.Open("C:\Users\umadevi.manjunath\Desktop\Copy of WP Closure 2015 2017.xlsx")
Set objWS = objWB.worksheets(1)
objXL.Visible = True
' MsgBox "Can you see what it is yet?"
file_name = objWS.Range("B691").Value
file_name = "<>\" & file_name
FileOpenEx Name:=file_name, ReadOnly:=False
'Show MS Project window
' projApp.Visible = True
' ProjectCheckOut
OptionsViewEx ProjectSummary:=True
TableEditEx Name:="&Entry", TaskTable:=True, NewName:="", NewFieldName:="Locked", Width:=20, ShowInMenu:=True, LockFirstColumn:=True, DateFormat:=255, RowHeight:=1, ColumnPosition:=11
TableApply Name:="&Entry"
SelectTaskField Row:=1, Column:="Locked"
SelectTaskField Row:=-1, Column:="Locked"
SetTaskField Field:="Locked", Value:="Yes"
' FileSave
FileCloseEx Save:=pjSave, CheckIn:=True
FileLoadLast
ProjectCheckOut
Publish
' Application.Wait (Now + TimeValue("00:00:20"))
FileCloseEx Save:=pjSave, CheckIn:=True
objWB.Close
End Sub