Elias Posted April 9, 2009 Share Posted April 9, 2009 How to convert Excel macros to AutoIt? (V 3.3.0.0)One thing I know, is necessary to have the xlxxxx constantsI Attached the file "Excel xl constants_complemet.au3" to this post;************************************************************;Enumerated Constants for CoClass "Excel.Application";Extracted from "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE";************************************************************#include-once ; 1470 new constants 74 commented exist in Excel.au3;ConstantsConst $xlAll = -4104;Const $xlAutomatic = -4105Const $xlBoth = 1;Const $xlCenter = -4108Const $xlChecker = 9Const $xlCircle = 8Const $xlCorner = 2Const $xlCrissCross = 16:: With this, the problem now is How to convert the variables of the macros created by Excel in the form Variable1:=Value1 Variable2:=Value3 Variable3:=Value4 to AutoIt formatI know the result will be something like this .method(value1, value2, etc..)In the Excel macro:Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=FalseIn AutoIt:Const $xlPasteValues = -4163 $oExcel.Selection.PasteSpecial($xlPasteValues,Default,Default,Default)How is made the magic? Where do I find the information PasteSpecial($Past, $Operation = Default,.....) ??????? Here is some exempls of Macros thas I was unable to convert to AutoIt:Sub Macro1()Columns("I:I").Select Selection.Insert Shift:=xlToRight Range("I2").Select ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-2]" Range("I2").Select Selection.AutoFill Destination:=Range("I2:I130") Range("I2:I130").SelectEnd SubSub Macro2()ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFiltering:=TrueEnd SubSub Macro3()ChDir "C:\TestDir" Workbooks.OpenText Filename:="C:\TestDir\test1.xxx", _ Origin:=xlMSDOS, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _ Array(0, 2), Array(25, 4), Array(31, 4), Array(37, 1), Array(40, 9), Array(55, 1), Array(62 _ , 1), Array(85, 1), Array(104, 1), Array(127, 1), Array(155, 1), Array(157, 1), Array(231, 1 _ )), TrailingMinusNumbers:=TrueEnd SubExcel_xl_constants_complemet.au3 Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 9, 2009 Share Posted April 9, 2009 Open the included Excel.au3 UDF file in SciTE and look at the many example in there. 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...
Elias Posted April 9, 2009 Author Share Posted April 9, 2009 Found the magic!In the Excel macro editorRight Click and select the Object finder (Pesquisador de Objetos)PS: My Excel is in PortuguesFind "insert", type "insert" and press [enter]Select Excel Range InsertThere is the result:Function Insert([shift], [CopyOrigin])In VB:Range("I:I").Insert Shift:=xlToRight In AutoIt: $oExcel.Activesheet.Range("I:I").Insert($xlToRight) or $oExcel.Activesheet.Range("I:I").Insert($xlToRight,Default) Hope this help's Link to comment Share on other sites More sharing options...
Elias Posted April 9, 2009 Author Share Posted April 9, 2009 Open the included Excel.au3 UDF file in SciTE and look at the many example in there. Thanks, the reason to ask how to convert VB to AutoIt is that recording a Macro in Excel is very efficient to make the codeand I did't find the resolution of what I needed in the examples. And I like to learn how it works, not just copy. 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