Copy txt file into excel vbscript


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Copy txt file into excel vbscript
# 1  
Old 08-03-2018
Copy txt file into excel vbscript

Hi everybody,

I am working on Windows 10 and using cygwin.
I have a vbscript as follows:

Code:
Set objExcel = CreateObject("Excel.Application")  
objExcel.Visible = True  
Set wb1 = objExcel.Workbooks.open("\\files\share\path\file1.xlsx") 
wb1.Worksheets("Sheet1").Range("A1:CR89").Clear
Set wb2 = objExcel.Workbooks.open("\\files\share\path\test.txt") 
wb2.Worksheets("test").usedrange.copy
wb1.Worksheets("Sheet1").usedrange.pastespecial
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c echo. >NUL  | clip", 0, True
wb2.Close
wb1.Save

I want at first to open file1.xlsx, delete cells in file1.xlsx, copy the content of the test.txt file inside file1.xlsx, and finally save and close file1.xlsx.

This script works, but I was wondering if there is a way to do the same task without having to open the test.txt file with excel? Something which would temporarily copy the content of test.txt without having this file opened.

Thanks in advance for any help.

Supernono06
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Copy the content from txt file and create a html file

I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the... (7 Replies)
Discussion started by: DevAakash
7 Replies

2. Shell Programming and Scripting

Copy data to CSV file from txt output

Hi Everyone , Below is output from a TL1 , I want just the NE Name: and beside that the Temperature and the voltages in a csv file , Is this possible? > act-user:AB1S2a:ArshadFO:493::**********; AB1S2a 2016-02-07 10:13:24 M 493 COMPLD "ArshadFO:2016-02-07 10-04-55,0" ;... (11 Replies)
Discussion started by: adgjmpt
11 Replies

3. Windows & DOS: Issues & Discussions

How to copy a file with long records ,i.e spanning to 2 or 3 lines from UNIX to excel?

Hi Experts, I have a Unix csv file which has long records ie the record length is more than 80 so it goes to the next line.So when its in unix though it spans to two or three lines it still counts it as one record. But what is happening is for the records that are long when i copy it into excel i... (0 Replies)
Discussion started by: 100bees
0 Replies

4. UNIX for Dummies Questions & Answers

How to copy a file opened in UNIX to word or txt?

Hi I would like to know how to copy a file opened in unix editor like Nedit or vi editor to a word document Since I am newbie I want to make sure I am not really copying onto real subdirectories I tried to right click and copy the entire .sql file or any other file opened.. Nedit doesn't... (3 Replies)
Discussion started by: swathi123
3 Replies

5. Shell Programming and Scripting

Copy Data from CSV file to Excel Sheet using Perl

Hi All, Firstly I will like to wish A Happy New Year to all. Now my issue is I have one csv file say(data.csv) and one excel file say(result.xls) The result.xls contains two sheet name Sheet1 and Sheet2, Now What I am trying to do is to First I want to delete that data of Sheet2 if present any,... (6 Replies)
Discussion started by: adisky123
6 Replies

6. Shell Programming and Scripting

Converting txt file to Excel file

Hi All, I have a text file with below content. TradeDate Name SecurityMnc ReasonDesc ======================================= 20120501 Robin ABC FO System Defect 20120502 Robin ABC FO System Defect I would want this in an excel file in 4 columns,... (3 Replies)
Discussion started by: robinbannis
3 Replies

7. Shell Programming and Scripting

Help with selecting column with awk for a txt file generated by excel

I am new to scripting/programming, so I apologize for any novice questions. I have a tab delimited text file that was saved from excel xls file. I am trying to select only the third column using awk command. My command line is as below: cat test.txt | awk '{print $3}' However, above... (8 Replies)
Discussion started by: SangLad
8 Replies

8. Windows & DOS: Issues & Discussions

Split Data in one column into 2 column in Excel using DOS or VBScript

Hi I have some data in my Excel File.However all the data is in one single column.I want to split it into two columns. Current Data: 1,Hi Everyone,I am 7,New To Dos,And 17,VB Script,i could 110,have tried this thing 1800,in UNIX Desired Output CELL1|CELL 2 1 |Hi... (3 Replies)
Discussion started by: dashing201
3 Replies

9. UNIX for Dummies Questions & Answers

Save Excel file as .txt in UNIX format

I have some files created in Excel that have to be saved as .txt files in order to load them into our accounting system. I can save the files as .txt files through Excel, but I then have to open them in TextPad and do a save as to change the Format from PC to UNIX. Is there a way to skip this step... (2 Replies)
Discussion started by: jroyalty
2 Replies

10. Shell Programming and Scripting

how to copy data to to excel file

Hi, Can any one tell me how to copy data using shell script to a excel file from text file to other columns of excel file,leaving first column unaffected i.e it should not overwrite data in first column. Say my text file data is: 15-dec-2008 15-dec-2009 16-dec-2008 16-dec-2009 ... (7 Replies)
Discussion started by: tucs_123
7 Replies
Login or Register to Ask a Question
Bio::SeqIO::excel(3pm)					User Contributed Perl Documentation				    Bio::SeqIO::excel(3pm)

NAME
Bio::SeqIO::excel - sequence input/output stream from a MSExcel-formatted table SYNOPSIS
#It is probably best not to use this object directly, but #rather go through the SeqIO handler system. Go: $stream = Bio::SeqIO->new(-file => $filename, -format => 'excel'); while ( my $seq = $stream->next_seq() ) { # do something with $seq } DESCRIPTION
This class transforms records in a MS Excel workbook file into Bio::Seq objects. It is derived from the table format module and merely defines additional properties and overrides the way to get data from the file and advance to the next record. The module permits specifying which columns hold which type of annotation. The semantics of certain attributes, if present, are pre- defined, e.g., accession number and sequence. Additional attributes may be added to the annotation bundle. See Bio::SeqIO::table for a complete list of parameters and capabilities. You may also specify the worksheet from which to obtain the data, and after finishing one worksheet you may change the name to keep reading from another worksheet (in the same file). This module depends on Spreadsheet::ParseExcel to parse the underlying Excel file. FEEDBACK
Mailing Lists User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated. bioperl-l@bioperl.org - General discussion http://bioperl.org/wiki/Mailing_lists - About the mailing lists Support Please direct usage questions or support issues to the mailing list: bioperl-l@bioperl.org rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible. Reporting Bugs Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via email or the web: https://redmine.open-bio.org/projects/bioperl/ AUTHOR - Hilmar Lapp Email hlapp at gmx.net APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ new Title : new Usage : $stream = Bio::SeqIO->new(-file => $filename, -format => 'excel') Function: Returns a new seqstream Returns : A Bio::SeqIO stream for a MS Excel format Args : Supports the same named parameters as Bio::SeqIO::table, except -delim, which obviously does not apply to a binary format. In addition, the following parameters are supported. -worksheet the name of the worksheet holding the table; if unspecified the first worksheet will be used worksheet Title : worksheet Usage : $obj->worksheet($newval) Function: Get/set the name of the worksheet holding the table. The worksheet name may also be a numeric index. You may change the value during parsing at any time in order to start reading from a different worksheet (in the same file). Example : Returns : value of worksheet (a scalar) Args : on set, new value (a scalar or undef, optional) close Title : close Usage : Function: Close and/or release the resources used by this parser instance. We override this here in order to free up the worksheet and other related objects. Example : Returns : Args : Internal methods All methods with a leading underscore are not meant to be part of the 'official' API. They are for use by this module only, consider them private unless you are a developer trying to modify this module. _worksheet Title : _worksheet Usage : $obj->_worksheet($newval) Function: Get/set the worksheet object to be used for accessing cells. Example : Returns : value of _worksheet (a Spreadsheet::ParseExcel::Worksheet object) Args : on set, new value (a Spreadsheet::ParseExcel::Worksheet object or undef, optional) _next_record Title : _next_record Usage : Function: Navigates the underlying file to the next record. We override this here in order to adapt navigation to data in an Excel worksheet. Example : Returns : TRUE if the navigation was successful and FALSE otherwise. Unsuccessful navigation will usually be treated as an end-of-file condition. Args : _get_row_values Title : _get_row_values Usage : Function: Get the values for the current line (or row) as an array in the order of columns. We override this here in order to adapt access to column values to data contained in an Excel worksheet. Example : Returns : An array of column values for the current row. Args : perl v5.14.2 2012-03-02 Bio::SeqIO::excel(3pm)