#1
|
|||
|
|||
Error setting temp macro in vbscript
Hi,
I am using this in my vbscript to set a temporary macro BatFile. Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile") MsgBox "%BatFile%" And then in the next step using the run program to run a bat file as follows: %DOSCMD% %DestinationDir%\%BatFile% But this gives me an error. What am I doing wrong? Thanks. |
#2
|
|||
|
|||
What's the error message? If either macro could contain spaces, you'll want to enclose the value in double quotes:
%DOSCMD% "%DestinationDir%\%BatFile%" |
#3
|
|||
|
|||
%DOSCMD% "%DestinationDir%\%BatFile%"
Changing it to this also gives the following error: The syntax of the command is incorrect. Process completed with exit code 1 Step 'Run Program' failed Also, in my VBScript MsgBox vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile") This pops the right value, but the one below pops up a messagebaox with : <object> Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile") MsgBox "%BatFile%" Also, the value destination dir is C:\Xfolder\bin |
#4
|
|||
|
|||
OK. Changing it to this:
Application.Macros(vbldTemporary).Add "BatFile", SFname and SFname is a string with the recordset value worked....for some reason. Thanks. |
#5
|
|||
|
|||
Your code stores the recordset field object rather than its value. Use
Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").V alue to store the field's value in the macro. |
#6
|
|||
|
|||
Hi,
I am trying to Set Macro called BatFile and giving the following in the value field like this: %vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile"). Value% or vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").V alue or vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile") or %vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile")% These are the errors I get: C:\PLTS\Bin\vbld_TempMacroObj' is not recognized as an internal or external command, operable program or batch file. Error expanding macros or script in property MacroValue: <Error parsing macros: Unrecoverable Parse Error at position 28 - expecting percent_sign> What should I use? |
#7
|
|||
|
|||
#8
|
|||
|
|||
Thanks!
I have another question: builder.RunProgram(%DOSCMD% "%DestinationDir%\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").V alue]") Adding this line to my vbscript code gives me error: Error in Run Script (VBScript) script code at Line 61, Column 33 (Expected ')') Code: builder.RunProgram(C:\WINDOWS\system32\cmd.exe /C "C:\PLTS\Bin\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").V alue]") But running this same command in Run program action: %DOSCMD% "%DestinationDir%\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").V alue]" runs fine. How can I incorporate this in the script? |
#9
|
|||
|
|||
This gives me the right value when I run the script:
MsgBox vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").V alue But builder.RunProgramEx(%DOSCMD% %DestinationDir%\vbld_TempMacroObj("ADO_RS").Field s("TLBIMPFile").Value) gives me the error: Error in Run Script (VBScript) script code at Line 62, Column 35 (Expected ')') Code: builder.RunProgramEx(C:\WINDOWS\system32\cmd.exe /C C:\PLTS\Bin\vbld_TempMacroObj("ADO_RS").Fields("TL BIMPFile").Value) |
|
|