Results 1 to 15 of 15

Method 'Run' of object '_Application' failed

Threaded View

brl8 Method 'Run' of object... 08-23-2010, 07:29 PM
shg Re: Method 'Run' of object... 08-23-2010, 07:36 PM
brl8 Re: Method 'Run' of object... 08-24-2010, 10:48 AM
shg Re: Method 'Run' of object... 08-24-2010, 10:51 AM
brl8 Re: Method 'Run' of object... 08-24-2010, 11:34 AM
romperstomper Re: Method 'Run' of object... 08-24-2010, 11:57 AM
brl8 Re: Method 'Run' of object... 08-24-2010, 01:04 PM
romperstomper Re: Method 'Run' of object... 08-24-2010, 01:31 PM
brl8 Re: Method 'Run' of object... 08-24-2010, 03:15 PM
romperstomper Re: Method 'Run' of object... 08-24-2010, 04:22 PM
sjain0909 Re: Method 'Run' of object... 04-17-2015, 08:38 AM
romperstomper Re: Method 'Run' of object... 04-17-2015, 11:54 AM
sjain0909 Re: Method 'Run' of object... 04-20-2015, 08:51 AM
sjain0909 Re: Method 'Run' of object... 04-21-2015, 01:31 AM
romperstomper Re: Method 'Run' of object... 04-21-2015, 04:27 AM
  1. #1
    Registered User
    Join Date
    07-14-2010
    Location
    Snowmass, Colorado
    MS-Off Ver
    Excel 2007
    Posts
    30

    Method 'Run' of object '_Application' failed

    Hi All,

    I have the following code, which is giving me the error: "Method 'Run' of object '_Application' failed" on this line:

    ActiveWorkbook.Application.Run ProjDir + "\" + "'Model Manager Extract Companion.xlsm!CallD2ResultsFunction'"
    I am trying to call a function from another spreadsheet after populating it with some data.

    Does anyone have any thoughts on why I might be getting the error message?

    Thanks!!

    Private Sub CommandButton3_Click()
    Dim OtherBook As String
    Dim ProjDir As String
    Dim ProjOutDir As String
    Dim ResultsFile As String
    Dim i As Integer
    Dim j As Integer
    Dim ManageArray() As String
    Dim LastCol As Integer
    
    
    
    'get values for project directory, output folder, batch numbers, batch run labels,
    'output file names, results filename, weather file
    
    With Sheets("Manage")
        ProjDir = .Cells(4, "G").Value
        ProjOutDir = .Cells(5, "G").Value
        ResultsFile = .Cells(6, "G").Value
    End With
    
    With Sheets("Batch Runs")
        'Get last column:
        LastCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
        'Fill an array with run number, base filename, batch run label, and location
        Debug.Print LastCol
        ReDim ManageArray(1 To LastCol - 1, 1 To 5)
        For i = 1 To LastCol - 1
                ManageArray(i, 1) = i
                ManageArray(i, 2) = .Cells.Find(What:="RUN", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlNext, _
                MatchCase:=True, SearchFormat:=False).Offset(0, i)
                ManageArray(i, 3) = .Cells.Find(What:="Base Filename", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlNext, _
                MatchCase:=True, SearchFormat:=False).Offset(0, i)
                ManageArray(i, 4) = .Cells.Find(What:="Batch Run Label", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlNext, _
                MatchCase:=True, SearchFormat:=False).Offset(0, i)
                ManageArray(i, 5) = .Cells.Find(What:="Location", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlNext, _
                MatchCase:=True, SearchFormat:=False).Offset(0, i)
                
        Next i
        
    End With
    
    'open eQuest extract file, rename it, and put the data onto sheet 2
    'test if the file exists first.
    'Debug.Print ProjDir + "\" + ResultsFile
    If Len(Dir(ProjDir + "\" + ResultsFile)) > 0 Then
    
    
        Workbooks.Open Filename:=ProjDir + "\" + ResultsFile
        OtherBook = ActiveWorkbook.Name
        
        With Sheets("Manager")
            .Cells(4, "B").Value = ProjDir
            .Cells(5, "B").Value = ProjOutDir
            .Cells(6, "B").Value = ResultsFile
            
            For i = LBound(ManageArray, 1) To UBound(ManageArray, 1)
                .Cells(8, i + 1).Value = ManageArray(i, 1)
                .Cells(9, i + 1).Value = ManageArray(i, 2)
                .Cells(10, i + 1).Value = ManageArray(i, 3)
                .Cells(11, i + 1).Value = ManageArray(i, 4)
                .Cells(12, i + 1).Value = ManageArray(i, 5)
                .Cells(13, i + 1).Value = ManageArray(i, 3) + " - " + ManageArray(i, 4) _
                     + " - Baseline Design"
            Next i
        End With
            If Len(Dir(ProjDir + "\Model Manager Extract Companion.xlsm")) > 0 Then
                'call the function in the Model Manager Extract Companion
                'Debug.Print ProjDir + "\" + "Model Manager Extract Companion.xlsm!CallD2ResultsFunction"
                ActiveWorkbook.Application.Run ProjDir + "\" + "'Model Manager Extract Companion.xlsm!CallD2ResultsFunction'"
               
            Else
            'File does not exist
            MsgBox ProjDir + "\Model Manager Extract Companion.xlsm not found.  Please ensure this file is in your project directory."
            End If
    Else
        'File does not exist
        MsgBox ResultsFile + " does not exist.  Please ensure you have a copy of this file with this name in the project folder listed on the model manager."
    End If
    
    End Sub
    Last edited by brl8; 08-29-2010 at 06:25 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1