Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Procedure Call or Argument Error

Status
Not open for further replies.

mmignot

Programmer
Jul 16, 2001
44
0
0
US
Hello all,

I have an excel macro that runs fine on my machine, but when the macro is used on a user's machine she gets the following error:

VBAProject - 5: Invalid procedure call or argument

We are both running Excel 2003.

I think I know where it is failing but I'm not sure why. Here is the code that does a call to the failing procedure:

Code:
' *----------------------------------------*
' * STEP05: Copy the Template Supplemental *
' *         form to a Supplemental Data    *
' *         Workbook.                      *
' *----------------------------------------*
' *
   Application.StatusBar = "STEP05: Copying Template WBs" 
   Call STEP05_CopySuppTempWB

Here is a copy of the code that is called:

Code:
Private Sub STEP05_CopySuppTempWB()

   On Error GoTo ErrorHandler

' *-------------------------------------------*
' * Change to Output folder path location.    *
' * Save Supplemental data to new output Sup- *
' * plemental Data Excel Workbook.            *
' *-------------------------------------------*
' *
   ChDir OutputDIR
   Application.DisplayAlerts = False                  ' ** Turn off Alerts **
   
' *-------------------------------------------*
' * Create Supplemental Data Workbook.        *
' *-------------------------------------------*
' *
   Worksheets("Sheet1").Select
   Cells.Select
   Selection.Copy
   Workbooks.Add
   Cells.Select
   ActiveSheet.Paste
   ActiveWindow.DisplayGridlines = False
   Application.CutCopyMode = False
   
   ActiveWorkbook.SaveAs Filename:=OutputDIR & "\SupplementalData.xls", _
                         FileFormat:=xlNormal, _
                         Password:="", _
                         WriteResPassword:="", _
                         ReadOnlyRecommended:=False, _
                         CreateBackup:=False
                         
' *-------------------------------------------*
' * Create Supplemental Data Errors Workbook. *
' *-------------------------------------------*
' *
   Windows("SupplementalData.xls").Visible = False
   Worksheets("Sheet2").Select
   Cells.Select
   Selection.Copy
   Workbooks.Add
   Cells.Select
   ActiveSheet.Paste
   ActiveWindow.DisplayGridlines = False
   Application.CutCopyMode = False
   
   ActiveWorkbook.SaveAs Filename:=OutputDIR & "\SupplementalData_Errors.xls", _
                         FileFormat:=xlNormal, _
                         Password:="", _
                         WriteResPassword:="", _
                         ReadOnlyRecommended:=False, _
                         CreateBackup:=False
      
' *-------------------------------------------*
' * Turn on alerts -- go back to Supplemental *
' * Data Workbook.                            *
' *-------------------------------------------*
' *
   Application.DisplayAlerts = True                   ' ** Turn Alerts Back On **
   Windows("SupplementalData_Errors.xls").Visible = False
   Windows("SupplementalData.xls").Visible = True
   Worksheets("Sheet1").Select
   Range("A1").Select

      
' *--------------------------------------*
' * Cleanup on exit.                     *
' *--------------------------------------*
' *
CleanUp:
   Exit Sub

' *--------------------------------------*
' *  Generate error number and message.  *
' *--------------------------------------*
' *
ErrorHandler:
   MsgBox Err.Source & " - " _
                     & Err.Number _
                     & ":  " _
                     & Err.Description, _
                     vbCritical, "Failure in SaveSuppDataWB()", vbOKOnly
   Resume CleanUp
  
End Sub

This works on my machine but not on another user's machine. Can anyone help me with this?

Thanks!

 
Hello all,

I found the issue. The folder path locations were too long. Once we shortened the paths the macro worked.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top