xcaliber13 Posted September 13, 2016 Share Posted September 13, 2016 In VBS you can import a text file into Excel with a xlFixedWidth Example: objExcel.Workbooks.OpenText "C:\temp\temp2.txt",,,xlFixedWidth,,,,,,,,, _ Array(Array(0, xlTextFormat),Array(8, xlTextFormat),Array(20, xlTextFormat),Array(31, xlTextFormat)) This lets me define the start and end of each column and the format of that column. Can I define the start and end of each column using _Excel_BookOpenText($oExcel, $sTextFile, Default, $xlFixedWidth) ? Thank you Link to comment Share on other sites More sharing options...
water Posted September 13, 2016 Share Posted September 13, 2016 According to MSDN you need to specify the starting position and the type in an array as described for xlDelimited in Example 1 of _Excel_BookOpenText. Details can be found here: https://msdn.microsoft.com/en-us/library/ff837097(v=office.14).aspx Section: Remarks - FieldInfo paramter Information My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
xcaliber13 Posted September 23, 2016 Author Share Posted September 23, 2016 Water, Just getting back to this one. Sorry for the delay. So in Example 1 of _Excel_BookOpenText Local $aField1[2] = [1, $xlTextFormat] Local $aField2[2] = [2, $xlTextFormat] Local $aField3[2] = [3, $xlGeneralFormat] Local $aField4[2] = [4, $xlDMYFormat] Local $aField5[2] = [5, $xlTextFormat] Local $aFieldInfo[5] = [$aField1, $aField2, $aField3, $aField4, $aField5] $aField1[2] <--- Is this the number [2] that is the starting position of the column? If not then where do I put the starting position of each column? Like the first column starts at position 0, the second column starts at position 20, the third column starts at position 30 Thank you Link to comment Share on other sites More sharing options...
water Posted September 23, 2016 Share Posted September 23, 2016 Yes. According to the help file: $aFieldInfo [optional] An array containing parse information for individual columns of data. The interpretation depends on the value of DataType. When the data is delimited, this argument is an array of two-element arrays, with each two-element array specifying the conversion options for a particular column. The first element is the column number (1-based), and the second element is one of the XlColumnDataType constants specifying how the column is parsed (default = keyword Default) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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