Sign in to follow this  
Followers 0
directbuy420

excel help

2 posts in this topic

#1 ·  Posted (edited)

Randall and Tone deaf, thanks for your help with this. I have modified the script to allow for choosing an excel file to be parsed.

I have one last question....any chance you can tell me where its declaring colum "A" to be read and output to the text file, i need to change it to a different column.

CODE

Opt("MustDeclareVars", 1)

; Declarations

Dim $oAppXL, $oWorkbook, $oWorksheet

Dim $hOutputFile

Dim $sWorkbookPath, $sOutputFilePath

; Flags declarations - Excel

Global Const $xlCellTypeLastCell = 11

; Initialize variables

$sWorkbookPath = $var

$sOutputFilePath = "C:\Documents and Settings\User\Desktop\GUI\Test.txt"

; Create Excel object

$oAppXL = ObjCreate("Excel.Application")

; Check if object creation succeeded

If Not IsObj($oAppXL) Then

MsgBox(16, "ActiveX Error", "Excel object creation failed." & @CRLF & _

"Please verify the installation of Microsoft Excel.")

Exit

EndIf

; Open workbook and text file

$oAppXL.Workbooks.Open($sWorkbookPath)

$hOutputFile = FileOpen($sOutputFilePath, 2)

; Find the opened workbook in all the workbooks that are open

For $i = 1 to $oAppXL.Workbooks.Count

If $oAppXL.Workbooks($i).FullName = $sWorkbookPath Then

$oWorkbook = $oAppXL.Workbooks($i)

EndIf

Next

; Associate first sheet in workbook with $oWorksheet

$oWorksheet = $oWorkbook.Worksheets(1)

; Read all rows in column A and write contents to output text file

For $i = 1 to $oWorksheet.Cells.SpecialCells($xlCellTypeLastCell).Row

FileWriteLine($hOutputFile, $oWorksheet.Cells($i, 1).Value)

Next

; Close files

FileClose($hOutputFile)

$oAppXL.Quit

Edited by directbuy420

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Randall and Tone deaf, thanks for your help with this. I have modified the script to allow for choosing an excel file to be parsed.

I have one last question....any chance you can tell me where its declaring colum "A" to be read and output to the text file, i need to change it to a different column.

FileWriteLine($hOutputFile, $oWorksheet.Cells($i, 1).Value)

the 1 designates the first column. you can change that. another thing you could do, would be to access the values with

$oWorksheet.range("A" & $i).property

where A can be any column, the $i is your iterator for what row, and property would be replaced with whatever property you want; text,value,value2,formula

***edit*** if you're comfortable with the way you have it already, then just modify it and go with that, just letting you know that you have an alternative that may be more intuitive to you, assuming that you use excel frequently.

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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  
Followers 0