none
Runtime Error 462: Remote server machine does not exist or unavailable.

    Question

  •  The following code exports data from excel to project. It works fine until it gets to the section marked below then gives me the Runtime Error 462 message HOWEVER, if I already have a copy of Project open, it sail through and does everything it's supposed to. Any ideas??

    Option Explicit
    
    Private Sub CommandButton2_Click()
        Call findDependencies
        'Call CopyDependencies
        Call openMSProjectFromExcel
        Call ClearDependencies
    End Sub
    
    Private Sub Worksheet_Activate()
        'UpdateCMD Me.Name
        If Application.DisplayAlerts Then Application.StatusBar = ""
        Call CreateMARTAMenu
    End Sub
    
    Sub findDependencies()
        Dim ThisCell1 As Range
        Dim ThisCell2 As Range
        
        For Each ThisCell1 In ThisWorkbook.Sheets("Device Status").Range("C76:C149")
            For Each ThisCell2 In ThisWorkbook.Sheets("Device Status").Range("B76:B149")
                If ThisCell1.Value = ThisCell2.Value Then
                    ThisCell1.Offset(, 15).Value = ThisCell2.Offset(, 12).Value
                    Exit For
                End If
                Next ThisCell2
            Next ThisCell1
    End Sub
    
    Sub openMSProjectFromExcel()
    Dim pjapp As Object
    Dim newProj As Object
    Dim ActiveProject As Object
    Dim lastRow As Long
    Dim x As Long
    Dim x2 As Long
    Dim x3 As Long
    Dim colour As Long
    Dim y As Long
    Dim projectvalue As Long
    Dim marker As Integer
    Dim marker2 As Integer
    Dim ProjectID As Long
    
    Set pjapp = CreateObject("MSProject.application")
    If pjapp Is Nothing Then
    MsgBox "Project is not installed"
    End
    End If
    pjapp.Visible = True
    Set newProj = pjapp.Projects.Add
    newProj.Title = "My New Project"
    Set ActiveProject = newProj
    x = 76
    x2 = 76
    x3 = 76
    y = 1
    marker = 0
    marker2 = 0
    projectvalue = 1
    ProjectID = 1
    
    Worksheets("Device Status").Range("R76:R149").Copy
    
    While (Sheets("Device Status").Cells(x2, 2).Value) <> ""
        Sheets("Device Status").Cells(x2, 14).Value = projectvalue
        Sheets("Device Status").Cells(x2, 15).Value = Sheets("Device Status").Cells(x2, 2).Value
        x2 = x2 + 1
        projectvalue = projectvalue + 1
    Wend
    
    
    
    While (Sheets("Device Status").Cells(x, 2).Value) <> ""
         newProj.Tasks.Add Name:=Sheets("Device Status").Cells(x, 2).Value
         newProj.Tasks(y).Finish = Sheets("Device Status").Cells(x, 12).Value
         If Sheets("Device Status").Cells(x, 6).Interior.ColorIndex <> 5 Then
            If marker = 0 Then
                newProj.Tasks(y).OutlineIndent
                marker = 1
            End If
            If Sheets("Device Status").Cells(x, 6).Interior.ColorIndex <> 33 Then
                newProj.Tasks(y).Duration = Sheets("Device Status").Cells(x, 6).Text
                If Sheets("Device Status").Cells((x - 1), 6).Interior.ColorIndex = 33 Then
                    newProj.Tasks(y).OutlineIndent
                    marker2 = 1
                End If
            ElseIf Sheets("Device Status").Cells((x + 1), 6).Interior.ColorIndex = 5 Then
                newProj.Tasks(y).OutlineOutdent
            ElseIf Sheets("Device Status").Cells(x, 6).Interior.ColorIndex = 33 Then
                If Sheets("Device Status").Cells((x - 1), 6).Interior.ColorIndex <> 5 Then
                    newProj.Tasks(y).OutlineOutdent
                End If
            End If
         ElseIf y > 1 Then
            newProj.Tasks(y).OutlineOutdent
            marker = 0
            If marker2 = 1 Then
                newProj.Tasks(y).OutlineOutdent
                marker2 = 0
            End If
         End If
         x = x + 1
         y = y + 1
    Wend
    
    
                        ERROR OCCURS HERE!!!!!
    
    
    SelectTaskColumn Column:="Predecessors"
        EditPaste
       
    Do
        colour = Sheets("Device Status").Cells(x3, 2).Interior.ColorIndex
        If colour = 15 Then
            colour = 15
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=colour, EndShape:=0, EndType:=0, EndColor:=0
        ElseIf colour = 35 Then
            colour = 3
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=colour, EndShape:=0, EndType:=0, EndColor:=0
        ElseIf colour = 22 Then
            colour = 1
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=colour, EndShape:=0, EndType:=0, EndColor:=0
        ElseIf colour = 36 Then
            colour = 2
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=colour, EndShape:=0, EndType:=0, EndColor:=0
        ElseIf colour = 36 Then
            colour = 4
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=colour, EndShape:=0, EndType:=0, EndColor:=0
        ElseIf colour = 33 Then
            colour = 4
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=5, StartShape:=2, StartType:=0, StartColor:=colour, MiddleShape:=2, MiddlePattern:=1, MiddleColor:=colour, EndShape:=2, EndType:=0, EndColor:=colour
        ElseIf colour = 5 Then
            colour = 5
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=5, StartShape:=2, StartType:=0, StartColor:=colour, MiddleShape:=2, MiddlePattern:=1, MiddleColor:=colour, EndShape:=2, EndType:=0, EndColor:=colour
        Else
            colour = 12
            GanttBarFormat TaskID:=ProjectID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=colour, EndShape:=0, EndType:=0, EndColor:=0
        End If
        ProjectID = ProjectID + 1
        x3 = x3 + 1
    Loop Until ProjectID = y
    End Sub
    
    Sub ClearDependencies()
        ActiveSheet.Range("N:N").Clear
        ActiveSheet.Range("O:O").Clear
        ActiveSheet.Range("R:R").Clear
    End Sub
    
    
    
    Friday, September 11, 2009 8:47 AM

Answers