Jump to content
sat6804

How to copy text file content to Excel sheet?

Recommended Posts

sat6804

How to copy text file content to Excel sheet?

Share this post


Link to post
Share on other sites
water

AutoIt comes with an UDF to work with Excel. Please have a look at functions _Excel_BookOpen or _Excel_BookOpenText and the example scripts in the help file.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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
robdogg1955

Could someone help me open a tab delimited file into excel? Here is what I have but I just cannot figure out how to change the delimiter to a tab. I know it should be simple. Using my script, I am browsing to a text file on my desktop. This way I can open files with different names. My only concern is opening text files that are tab delimited. Any help will be greatly appreciated. I guess my only problem is with the last line in the following code.

#include <File.au3>
#include <Excel.au3>

Opt("MustDeclareVars", 1)

Global $oExcel, $sFilePath, $Default_Folder, $File_Type
Global $Result, $sDelimiter

$oExcel = _Excel_Open()
$sDelimiter = @Tab
$Default_Folder = @DesktopDir
$File_Type = "Text (*.txt)"
$sFilePath = FileOpenDialog("Find File", $Default_Folder, $File_Type, $FD_FILEMUSTEXIST)
If $sFilePath = "" Then
        MsgBox($MB_ICONWARNING, "Error", "No file chosen")
        Exit
EndIf
$Result = _Excel_BookOpenText($oExcel, $sFilePath, $sDelimiter)

 

Data.au3

Share this post


Link to post
Share on other sites
water

Please check the help file for _Excel_BookOpenText. Delimiter is parameter #7.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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
robdogg1955

Please check the help file for _Excel_BookOpenText. Delimiter is parameter #7.

I had be looking at the help file and just not quite understanding. I've played with it some more and it is working now.

Here is what I ended up with:

$Result = _Excel_BookOpenText($oExcel, $sFilePath, 1, Default, $xlTextQualifierDoubleQuote, False, @Tab, Default, Default, Default, True)

But thank you for taking the time to respond Water. It is truly a great work you have and are doing with AutoIt.

Share this post


Link to post
Share on other sites
water

Thanks. Glad you like the UDF :) 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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

×