tags:

views:

25

answers:

2

I created the following batch file using VB:

Open sBatchFile For Output As #1
    Print #1, "@ECHO OFF"
    Print #1, "ECHO Converting Excel Files to PDF, Please wait..."
    Print #1, "batchpdf ""\\Tiltonsrv1\officeplantshared\Schedule_3.xls"" ""\\Tiltonsrv1\officeplantshared\SHIFT_SCHEDULES\"" &fileName& "
    Close #1

    i = Shell(sBatchFile, vbMaximizedFocus)

    Application.Quit
End Sub

But the variable fileName isn't recognized. Am I putting it into the file correctly?

+3  A: 

I think you want:

Open sBatchFile For Output As #1 
Print #1, "@ECHO OFF" 
Print #1, "ECHO Converting Excel Files to PDF, Please wait..." 
Print #1, "batchpdf ""\\Tiltonsrv1\officeplantshared\Schedule_3.xls"" ""\\Tiltonsrv1\officeplantshared\SHIFT_SCHEDULES\" & fileName & """ "
Close #1 

i = Shell(sBatchFile, vbMaximizedFocus) 

Application.Quit 
LittleBobbyTables
Didn't seem to work. Just errors as usual.
BioXhazard
Sorry, I still had the quote in the wrong spot, try my last edit
LittleBobbyTables
Perfect. Thanks a lot.
BioXhazard
A: 
  1. Can you give us more about the error?
  2. Is there an Option Explicit at the beginning of your module? It would require that all variables be declared with a Dim statement
jonhwilliams