Hi I have a code that opens up a Project file and calls another macro to change some dates.
Sub Baseline()
'Deletes some columns
Columns("A
").Select
Selection.EntireColumn.Delete
Columns("B:S").Select
Selection.EntireColumn.Delete
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").Select
Selection.ColumnWidth = 100
Range("A1").Select
Selection.EntireRow.Delete
Dim Proj As Object
' Dim ProjName As Object
'From a spreadsheet and from Column A picks up the name of project to open.
For Each a In Range("A:A")
ProjName = a.Value
Set WshShell = CreateObject("WScript.Shell")
'Open MS Project and log on to the server
WshShell.Run "winproj.exe /s "" & "", 1, False
'waits 15 sec
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 15
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Set Proj = GetObject(, "MSProject.Application")
Proj.Visible = True
Proj.FileClose
Proj.DisplayAlerts = False
'opens up the project
Proj.FileOpen "<>\" & ProjName
'runs the macro from the personal spreadsheet
Application.Run ("PERSONAL.xls!ChangeBaseline")
Proj.FileSave
Proj.Quit
'waits another 15 secs
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 20
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Next
End Sub
The first time the code is running perfectly. Second time it gives me a weird error while trying run the macro. Its says the remote server is unavailable.
Does anyone know why am I having this error?
Also for some reason if the Project cannot open up a project since it was checked out. Can a macro store that information in a log?
Sub Baseline()
'Deletes some columns
Columns("A
Selection.EntireColumn.Delete
Columns("B:S").Select
Selection.EntireColumn.Delete
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").Select
Selection.ColumnWidth = 100
Range("A1").Select
Selection.EntireRow.Delete
Dim Proj As Object
' Dim ProjName As Object
'From a spreadsheet and from Column A picks up the name of project to open.
For Each a In Range("A:A")
ProjName = a.Value
Set WshShell = CreateObject("WScript.Shell")
'Open MS Project and log on to the server
WshShell.Run "winproj.exe /s "" & "", 1, False
'waits 15 sec
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 15
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Set Proj = GetObject(, "MSProject.Application")
Proj.Visible = True
Proj.FileClose
Proj.DisplayAlerts = False
'opens up the project
Proj.FileOpen "<>\" & ProjName
'runs the macro from the personal spreadsheet
Application.Run ("PERSONAL.xls!ChangeBaseline")
Proj.FileSave
Proj.Quit
'waits another 15 secs
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 20
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Next
End Sub
The first time the code is running perfectly. Second time it gives me a weird error while trying run the macro. Its says the remote server is unavailable.
Does anyone know why am I having this error?
Also for some reason if the Project cannot open up a project since it was checked out. Can a macro store that information in a log?