Run-Time error 462

I

Ian B

I have a script that starts MS Project and opens a project file (.mpp) and
then copies some of the data over into excel.

The first time i run it there is no problem but if i run it again i get a
error

Run-time error 462

The remote server machine does not exist or is unavalable

can anyone help me

CODE

Sub project()
'
Set mwb = Workbooks("Project_Plan.xls")
Set pd = Sheets("Project Data")
Set sp = Sheets("Baseline")
Set sf = Sheets("Forecast")
Set sa = Sheets("Actual")
Set se = Sheets("Control")
Set st = Sheets("Temp")
'
'
Dim proApp As MSProject.Application
Dim proDoc As MSProject.Projects
'
plen = pd.Range("plen")
sdate = pd.Range("sdate")
fdate = pd.Range("fdate")
plen = Application.WorksheetFunction.RoundUp(plen, 0)
'
Set proApp = CreateObject("MSProject.Application")
proApp.Visible = True
proApp.FileOpen Name:="H:\Work\VBA Macro\a1.mpp", ReadOnly:=False,
FormatID:="MSProject.MPP"
'
pveiew = MSProject.ActiveProject.CurrentView
If pview = "Task Usage" Then
Else
ViewApply Name:="Task Usage"
End If
'
OutlineShowTasks OutlineNumber:=pjTaskOutlineShowLevel1
PaneNext
SelectTimescaleRange Row:=1, StartTime:=sdate, Width:=plen + 3, Height:=1
EditCopy
'
ViewApply Name:="Gantt Chart"
'
mwb.Activate
st.Select
st.Range("A1").Select
ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
DisplayAsIcon:=False
'
proApp.DisplayAlerts = False
proApp.FileClose
proApp.DisplayAlerts = True
proApp.Quit ' close the application
'
mwb.Activate
se.Select
'
End Sub
 

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