0

I am attempting to run this script

if WScript.Arguments.Count < 1 Then   
WScript.Echo "Drop file on to me to process."   
Wscript.QuitEnd If
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
Set oVBC = oBook.VBProject.VBComponents oVBC.Import("C:\Test\Test.bas") 
oBook.Application.Run "Test" 
WScript.Echo "Done"

The name of the macro inside of the Test.bas file is Test() and the file is located at C:\Test\Test.bas - now anytime I try to drag a .xlsx file on top of the .vbscript I get an error that reads

Syntax error
800A03EA
Microsoft VBScript Compilation error

What needs to be altered in this script to remedy that issue?

1 Answer 1

1

Wscript.QuitEnd If Needs to be fixed to

Wscript.Quit End If

Set oVBC = oBook.VBProject.VBComponents oVBC.Import("C:\Test\Test.bas") to

Set oVBC = oBook.VBProject.VBComponents oVBC.Import("C:\Test\Test.bas")

Sign up to request clarification or add additional context in comments.

7 Comments

Changing that syntax gives me an error on line 7 - Expected End Of statement.
Set oVBC = oBook.VBProject.VBComponents oVBC.Import("C:\Test\Test.bas") Try bringing oVBC.Import("C:\Test\Test.bas") down a line.
Yes, that got it! It produces the file as needed but I get an Unknown Runtime Error as well?
-- would prefer to avoid just a random on error resume next if possible
It does not show me the line. It seems the script is run to completion as the file is generated just as I need. I don't understand the error, haha
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.