Jump to content
Sign in to follow this  
anthonyjr2

Importing a text file with Excel

Recommended Posts

anthonyjr2

Hey everyone,

Recently started using AutoIt at work again and came up with this interesting problem. I'm trying to import a .txt file in Fixed Width mode, except the columns need to be slightly modified before the import completes. Usually this would be done by moving them over in the wizard, but I don't see if there is a way to do this automatically through AutoIt. I would rather not have to do it using MouseMove() on the import wizard but if that is my only solution that's what I will end up doing.

I'm currently using 

_Excel_BookOpenText($oExcel, @ScriptDir & "\419.txt", Default, $xlFixedWidth)

Which opens the file with incorrect column widths. I can't seem to find an option in the UDF to be able to change the widths of the column at all. They will always be the same size so if there was a way for me to just hardcode the width number in I could do what I need.

Any suggestions/Is this possible? Thanks for any help.


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites
water

Please check https://msdn.microsoft.com/en-us/vba/excel-vba/articles/workbooks-opentext-method-excel  for the FieldInfo information about fixed width input files.

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
anthonyjr2

Doh, I figured there was something like that but didn't see it on the AutoIt help file since it only mentioned stuff about Delimited files.

Found what I needed, thanks for the quick reply water.


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites
water

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×