在批处理文件中使用VB变量

时间:2010-07-13 15:50:08

标签: vb6 dos

我使用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

但是无法识别变量fileName。我是否正确地将其放入文件中?

1 个答案:

答案 0 :(得分:3)

我想你想要:

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