martmeister Posted July 23, 2009 Share Posted July 23, 2009 Here is my code: #include <Excel.au3> run ("C:\Program Files\Microsoft Office\Office12\EXCEL.exe") ;opens excel winwaitactive ("Microsoft Excel - Book1") sleep (900) Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\programHopper.xlsm") WinWait("Microsoft Excel - programHopper.xlsm") Sleep(2000) $oExcel.Run("MacroHop") The Last Line Is Where Im Getting My Error..ehh, I dont know why its not running the macro called MacroHop The Macro is Part of the the program Hopper and works correctly when I manually run it so i know it works. I just need some help automating this. lol thanks! Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 24, 2009 Share Posted July 24, 2009 Here is my code: #include <Excel.au3> run ("C:\Program Files\Microsoft Office\Office12\EXCEL.exe") ;opens excel winwaitactive ("Microsoft Excel - Book1") sleep (900) Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\programHopper.xlsm") WinWait("Microsoft Excel - programHopper.xlsm") Sleep(2000) $oExcel.Run("MacroHop") The Last Line Is Where Im Getting My Error..ehh, I dont know why its not running the macro called MacroHop The Macro is Part of the the program Hopper and works correctly when I manually run it so i know it works. I just need some help automating this. lol thanks! You may be getting the wrong instance of Excel in $oExcel because you opened it with Run() and then did _ExcelBookOpen() also. What happens if you close all instances of Excel and then just do: #include <Excel.au3> Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\programHopper.xlsm") WinWait("Microsoft Excel - programHopper.xlsm") Sleep(2000) $oExcel.Run("MacroHop") If it still doesn't work, then post exactly what error you are getting. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
martmeister Posted July 24, 2009 Author Share Posted July 24, 2009 thanks man. I will try that tonight and get back to you Link to comment Share on other sites More sharing options...
martmeister Posted July 27, 2009 Author Share Posted July 27, 2009 You may be getting the wrong instance of Excel in $oExcel because you opened it with Run() and then did _ExcelBookOpen() also. What happens if you close all instances of Excel and then just do: #include <Excel.au3> Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\programHopper.xlsm") WinWait("Microsoft Excel - programHopper.xlsm") Sleep(2000) $oExcel.Run("MacroHop") If it still doesn't work, then post exactly what error you are getting. >_< It is still not working. It errors out when it open the file with "pic- autoit error message" is there something in excel where i can enable/disable this not to popup..?autoit error message.bmp Link to comment Share on other sites More sharing options...
martmeister Posted July 27, 2009 Author Share Posted July 27, 2009 It is still not working. It errors out when it open the file with "pic- autoit error message" is there something in excel where i can enable/disable this not to popup..?autoit error message.bmp never mine i solved my pop-up problem Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 27, 2009 Share Posted July 27, 2009 It is still not working. It errors out when it open the file with "pic- autoit error message" is there something in excel where i can enable/disable this not to popup..?autoit error message.bmp I'm not sure you can prevent that message, but you can handle it: #include <Excel.au3> Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\programHopper.xlsm") ; Handle link warning within 30sec Global $iTimer = TimerInit() While 1 If WinExists("Microsoft Office Excel", "This workbook contains one or more links that cannot be updated.") Then ControlSend("Microsoft Office Excel", "This workbook contains one or more links that cannot be updated.", "", "{ENTER}") ExitLoop ElseIf TimerDiff($iTimer) >= 30 * 1000 Then MsgBox(64, "Timeout", "30 sec timeout expired without seeing links warning") ExitLoop EndIf WEnd Sleep(2000) $oExcel.Run("MacroHop") >_< Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
martmeister Posted July 29, 2009 Author Share Posted July 29, 2009 I'm not sure you can prevent that message, but you can handle it: #include <Excel.au3> Global $oExcel = _ExcelBookOpen("C:\Documents and Settings\programHopper.xlsm") ; Handle link warning within 30sec Global $iTimer = TimerInit() While 1 If WinExists("Microsoft Office Excel", "This workbook contains one or more links that cannot be updated.") Then ControlSend("Microsoft Office Excel", "This workbook contains one or more links that cannot be updated.", "", "{ENTER}") ExitLoop ElseIf TimerDiff($iTimer) >= 30 * 1000 Then MsgBox(64, "Timeout", "30 sec timeout expired without seeing links warning") . >_< Thanks I fixed it. I have another question after programhopper how would i select a worksheet in the excel workbook? Would this work after opening: $oExcel = ObjCreate("programHopper") ; Create an Excel Object WITH $oExcel .Visible = 1 ; Let Excel show itself .Workbooks.Open "worksheetnumber4.xls" ; Open workbook .Run "MacroHop" ; Run macro .Quit ; Quit Excel ENDWITH... will this exit excel all together? Would that work. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 30, 2009 Share Posted July 30, 2009 Thanks I fixed it. I have another question after programhopper how would i select a worksheet in the excel workbook?Would this work after opening:$oExcel = ObjCreate("programHopper") ; Create an Excel Object WITH $oExcel .Visible = 1 ; Let Excel show itself .Workbooks.Open "worksheetnumber4.xls" ; Open workbook .Run "MacroHop" ; Run macro .Quit ; Quit Excel ENDWITH... will this exit excel all together?Would that work.You have to put parameters passed to methods inside parens, i.e. ".Run('MacroHop')". Other than that, I don't see why it wouldn't work. What happened when you tried it? >_< Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now