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. |
What's the error message? If either macro could contain spaces, you'll want to enclose the value in double quotes:
%DOSCMD% "%DestinationDir%\%BatFile%" |
%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 : |
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. |
Your code stores the recordset field object rather than its value. Use
Application.Macros(vbldTemporary).Add "BatFile", vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value to store the field's value in the macro. |
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").Value 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: What should I use? |
|
Thanks!
I have another question: builder.RunProgram(%DOSCMD% "%DestinationDir%\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value]") 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").Value]") But running this same command in Run program action: %DOSCMD% "%DestinationDir%\[vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value]" runs fine. How can I incorporate this in the script? |
This gives me the right value when I run the script:
MsgBox vbld_TempMacroObj("ADO_RS").Fields("TLBIMPFile").Value But builder.RunProgramEx(%DOSCMD% %DestinationDir%\vbld_TempMacroObj("ADO_RS").Fields("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("TLBIMPFile").Value) |
All times are GMT -5. The time now is 10:10 PM. |
Copyright © 1999-2023 Kinook Software, Inc.