Jump to content

Excel Macros and Errors


Faedien
 Share

Recommended Posts

Hello all, 

I've lurked around here for a while and learned a ton from everyone, but I can't see this issue anywhere.  I've been running macros through Autoit for a while in a number of programs, but I'm having some issues with this one.

Func RunMacro()
    Local $oExcel = _Excel_Open(False, False, False, False) ;Excel Program
    Local $oWorkbook = _Excel_BookOpen($oExcel, "C:/Equity Helper/Scripts/calendarmacros.xlsm", Default, Default, True)
    $oExcel.Run("calendarmacros.xlsm!Calendar")
EndFunc

When I run this bit of code everything works fine as long as the macro gets to finish.  But the actual VBA calls two "Application.UserInput" fields, and if I cancel out of either the macro closes, and then AutoIt throws an error at--

$oExcel.(<---error throws here)Run("calendarmacros.xlsm!Calendar")

I don't want to use autoit for the user inputs if possible, it's just easier to get the data I need for the inputs from within the VBA environment, but I'm afraid that's what's causing the problem.

Link to comment
Share on other sites

  • Moderators

When you cancel out are you closing Excel altogether? That error is telling you the $oExcel object (the Excel application object) no longer exists.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...