Laurent Posted June 20, 2007 Share Posted June 20, 2007 (edited) Hello, I have to admit I'm newbie with AutoIt (find it really cool anyway), and I already searched the forum for an answer to my problem ... but couldn't find what I'm looking for So my problem is in fact the following --> Is it possible to pass some parameters from within an AutoIt Script to an Excel file macro, and after execution and closure, retrieve those parameters back into the script to be able to pass them to a Word Macro for execution ? Here's some code I've tried ... I'm able to launch & execute both macros, but the parameters are always empty :-( Local $DateTreated = "" Local $AutoTreat = "" Local $DraftOrSend = "" Local $LogFileLocation = "" Local $strExcelMacroName = "Treatment" Local $strWordMacroName = "Treatment" MsgBox(0, "Affichage", $DateTreated & " " & $AutoTreat & " " & $DraftOrSend & " " & $LogFileLocation) #include <ExcelCOM_UDF.au3> ; Include the Excel collection $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel = _ExcelBookOpen ("C:\Backup and Personal files\Macros\GenCust_Tri_Pudo CH_Automated.xls") $oExcel.Visible = 1 ; Let Excel show itself $oExcel.Application.Run($strExcelMacroName , $DateTreated, $AutoTreat, $DraftOrSend, $LogFileLocation) ; Add a new workbook MsgBox(0, "Affichage", $DateTreated & " " & $AutoTreat & " " & $DraftOrSend & " " & $LogFileLocation) $oExcel.Quit ; Quit Excel MsgBox(0, "Affichage", $DateTreated & " " & $AutoTreat & " " & $DraftOrSend & " " & $LogFileLocation) #include <Word.au3> MsgBox(0, "Affichage", $DateTreated & " " & $AutoTreat & " " & $DraftOrSend & " " & $LogFileLocation) $oWordApp = _WordCreate ("C:\Backup and Personal files\Macros\GenCust_Fax_Pudo CH.dot") MsgBox(0, "Affichage", $DateTreated & " " & $AutoTreat & " " & $DraftOrSend & " " & $LogFileLocation) _WordMacroRun ($oWordApp, $strWordMacroName , $DateTreated, $AutoTreat, $DraftOrSend, $LogFileLocation) _WordQuit ($oWordApp, 0) would be great if someone could assist me here :-) regards Laurent. Edited June 20, 2007 by Laurent Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 20, 2007 Moderators Share Posted June 20, 2007 I tried the following without success. #include <Word.au3> #cs (Test Macro) Sub MacroTestByRef(ByRef v_Arg) v_Arg = "After" End Sub #ce $vArg = "Before" $sFilePath = @ScriptDir & "\ByRef.doc" $oWordApp = _WordCreate($sFilePath, 0, 0) __WordMacroRun($oWordApp, "MacroTestByRef", $vArg) _WordQuit($oWordApp, 0) ConsoleWrite($vArg & @CR) Func __WordMacroRun(ByRef $o_object, $s_MacroName, ByRef $v_Arg1) $o_object.Run($s_MacroName, $v_Arg1) EndFunc ;==>__WordMacroRun It appears AutoIt does not support ByRef in this case. This would be a good feature request. Link to comment Share on other sites More sharing options...
Laurent Posted June 21, 2007 Author Share Posted June 21, 2007 Thanks anyway big_daddy - I already tried several things (but I'm far away from beeing a "specialist") without any success neither :-( I've now found a turn around for my case here --> I'm starting the Word Macro from within the Excel macro, passing to it the needed parameters ... it's working fine like this, but it's not as "clean" as I would have expected ... as you wrote, it would be a good feature to add regards Laurent. Link to comment Share on other sites More sharing options...
UQOII Posted June 21, 2007 Share Posted June 21, 2007 (edited) @ Laurent's script I am trying to make a script with excel functions but my Autoit doesn't know: #include <ExcelCOM_UDF.au3> Have you download this after the instalation? (i cann't found it in the download, and i have also Autoit 3) Edited June 21, 2007 by UQOII [center]uqoii.nl[/center] Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted June 21, 2007 Moderators Share Posted June 21, 2007 I am trying to make a script with excel functions but my Autoit doesn't know: #include <ExcelCOM_UDF.au3> Have you download this after the instalation? (i cann't found it in the download, and i have also Autoit 3)There's a link for it here. Link to comment Share on other sites More sharing options...
Laurent Posted July 9, 2007 Author Share Posted July 9, 2007 Thanks big_daddy for replying for me ... by chance you were here so UQOII didn't had to wait 'till I came back in the forum Regards Laurent 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