Runtime error 5 when creating batch file (USED TO WORK)

chrisignm

Active Member
Joined
Apr 1, 2014
Messages
273
Hello. I am getting "Runtime error 5, Invalid Procedure call or argument error when creating a pivot table" when executing the following macro to upload a file to FTP (it used to work and Paths are correct!)

Thats the macro:

Code:
Sub UploadFileReseller2()
Dim strDirectoryList As String
Dim lStr_Dir As String
Dim lInt_FreeFile01 As Integer
Dim lInt_FreeFile02 As Integer
Dim OrigFilePath2 As String
Dim OrigFilePath3 As String
Dim ResellerFile As String


Worksheets("Calc1").Range("A34:A35").Calculate
    OrigFilePath2 = [OrigFilePath]
    OrigFilePath3 = [OrigFilePathPath]
    ResellerFile = "Stock_List_Reseller2.xlsx"


On Error GoTo Err_Handler
    lStr_Dir = ThisWorkbook.Path
    lInt_FreeFile01 = FreeFile
    lInt_FreeFile02 = FreeFile


    '' ANW  07-Feb-2003 :
    strDirectoryList = lStr_Dir & "\Directory"


    '' Delete completion file
    If Dir(strDirectoryList & ".out") <> "" Then Kill (strDirectoryList & ".out")


    '' Create text file with FTP commands
    Open strDirectoryList & ".txt" For Output As #lInt_FreeFile01
    Print #lInt_FreeFile01, "open alaba2.bplaced.net"
    Print #lInt_FreeFile01, "alaba2_alaba2"
    Print #lInt_FreeFile01, "bla99999"
    'Print #lInt_FreeFile01, "cd source/uploads"
    Print #lInt_FreeFile01, "binary"
    'Print #lInt_FreeFile01, "delete " & "Stock_List_Reseller1.xlsx"
    Print #lInt_FreeFile01, "send " & OrigFilePath3 & ResellerFile & " " & ResellerFile


    '' To receive a file, replace the above line with this one
    ''Print #lInt_FreeFile01, "recv \Picture.gif " & ThisWorkbook.Path & "\Picture.gif"
    
    Print #lInt_FreeFile01, "bye"
    Close #lInt_FreeFile01


    '' Create Batch program
    Open strDirectoryList & ".bat" For Output As #lInt_FreeFile02
    Print #lInt_FreeFile02, "ftp -s:" & strDirectoryList & ".txt"


    Print #lInt_FreeFile02, "Echo ""Complete"" > " & strDirectoryList & ".out"
    Close #lInt_FreeFile02


    '' Invoke Directory List generator
    Shell (strDirectoryList & ".bat"), vbHide '', vbMinimizedNoFocus
    'Wait for completion
    Do While Dir(strDirectoryList & ".out") = ""
        DoEvents
    Loop


    Application.Wait (Now + TimeValue("0:00:03"))


    '' Clean up files
    If Dir(strDirectoryList & ".bat") <> "" Then Kill (strDirectoryList & ".bat")
    If Dir(strDirectoryList & ".out") <> "" Then Kill (strDirectoryList & ".out")
    If Dir(strDirectoryList & ".txt") <> "" Then Kill (strDirectoryList & ".txt")


bye:


Exit Sub


Err_Handler:
    MsgBox "Error : " & Err.Number & vbCrLf & "Description : " & Err.Description, vbCritical
    Resume bye


End Sub

Unfortunately it doesnt say which line it fails.

Thanks for any help :)
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,216,071
Messages
6,128,622
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top