Jump to content
Sign in to follow this  
Mun

[Solved] Convert Excel VBProject to Autoit.

Recommended Posts

Mun

Can anyone help me convert this to autoit natively?

With ActiveSheet.QueryTables.Add(Connection:= _
     "TEXT;" & CStr(TxtName), Destination:=Range("$A$1"))
     .Name = "Data"
     .FieldNames = True
     .RowNumbers = False
     .FillAdjacentFormulas = False
     .PreserveFormatting = True
     .RefreshOnFileOpen = False
     .RefreshStyle = xlInsertDeleteCells
     .SavePassword = False
     .SaveData = True
     .AdjustColumnWidth = True
     .RefreshPeriod = 0
     .TextFilePromptOnRefresh = False
     .TextFilePlatform = 437
     .TextFileStartRow = 1
     .TextFileParseType = xlFixedWidth
     .TextFileTextQualifier = xlTextQualifierDoubleQuote
     .TextFileConsecutiveDelimiter = False
     .TextFileTabDelimiter = True
     .TextFileSemicolonDelimiter = False
     .TextFileCommaDelimiter = False
     .TextFileSpaceDelimiter = False
     .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
     .TextFileFixedColumnWidths = Array(14, 16, 17, 18, 16, 14)
     .TextFileTrailingMinusNumbers = True
     .Refresh BackgroundQuery:=False
End With

I tried to search all forum and closest unanswer is this thread. ()

Little help please from all Excel Expert.

Edited by Mun

Share this post


Link to post
Share on other sites
Mun

After many trial and error, reading all documents - I have successfully parse all of these into Autoit code.

I post the code for reference and anyone who needed.

Global Const $xlFixedWidth=2
Global Const $xlTextQualifierDoubleQuote=1
Global $Array[7] = [1, 1, 1, 1, 1, 1, 1]
Global $Array2[6] = [14, 16, 17, 18, 16, 14]


    With $oExcel.ActiveSheet
        .QueryTables.Add("TEXT;" & $Where, $oExcel.ActiveSheet.Range("$A$1"))
        .QueryTables(1).Name = "Data"
        .QueryTables(1).FieldNames = True
        .QueryTables(1).RowNumbers = False
        .QueryTables(1).FillAdjacentFormulas = False
        .QueryTables(1).PreserveFormatting = True
        .QueryTables(1).RefreshOnFileOpen = False
        .QueryTables(1).RefreshStyle = $xlInsertDeleteCells
        .QueryTables(1).SavePassword = False
        .QueryTables(1).SaveData = True
        .QueryTables(1).AdjustColumnWidth = True
        .QueryTables(1).RefreshPeriod = 0
        .QueryTables(1).TextFilePromptOnRefresh = False
        .QueryTables(1).TextFilePlatform = 437
        .QueryTables(1).TextFileStartRow = 1
        .QueryTables(1).TextFileParseType = $xlFixedWidth
        .QueryTables(1).TextFileTextQualifier = $xlTextQualifierDoubleQuote
        .QueryTables(1).TextFileConsecutiveDelimiter = False
        .QueryTables(1).TextFileTabDelimiter = True
        .QueryTables(1).TextFileSemicolonDelimiter = False
        .QueryTables(1).TextFileCommaDelimiter = False
        .QueryTables(1).TextFileSpaceDelimiter = False
        .QueryTables(1).TextFileColumnDataTypes = $Array
        .QueryTables(1).TextFileFixedColumnWidths = $Array2
        .QueryTables(1).TextFileTrailingMinusNumbers = True
        .QueryTables(1).Refresh
    EndWith

Share this post


Link to post
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
Sign in to follow this  

×