Jump to content

How to copy text file content to Excel sheet?


Recommended Posts

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 2022-02-19 - Version 1.6.1.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 (NEW 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

  • 1 month later...

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

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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.

Link to comment
Share on other sites

Thanks. Glad you like the UDF :) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...