Consulting

Results 1 to 19 of 19

Thread: Create BAT file that opens CMD then directory and runs program from that directory

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    623
    Location
    Untested :

    Sub CreateBatchFile()    
        Dim filePath As String
        Dim fileNumber As Integer
        Dim batchCommands As String
        filePath = "C:\PathToYourFolder\CombinePDFs.bat"
        fileNumber = FreeFile
        batchCommands = "cd /d C:\MIHAI\DOC\ASIG\DOSARE" & vbCrLf & _
        "pdftk.exe *.pdf cat output combined.pdf" & vbCrLf & "exit"
        Open filePath For Output As #fileNumber
        Print #fileNumber, batchCommands
        Close #fileNumber
        Shell filePath, vbNormalFocus
    End Sub
    Last edited by Aussiebear; 12-24-2024 at 05:30 PM.

Posting Permissions

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