Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default import batch file to excel

Hi all,

Using Excel2002, trying to open a batch file and copy to another sheet
within a workbook, however I am getting a file not found error, even though
it is definitely there. Any suggestions?

Sub import_batch()

Workbooks.OpenText Filename:="batch.BAT", Origin _
:=xlWindows, startrow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=True, other:=False, FieldInfo:=Array(1, 1)

Workbooks("batch.BAT").Activate
Range("a1", Range("a1").End(xlDown).End(xlToRight)).Copy
ThisWorkbook.Activate
JumperInput.Activate
ActiveSheet.Paste Destination:=Worksheets("JumperInput").Range("a1")
Application.CutCopyMode = False
Workbooks("batch.BAT").Close SaveChanges:=False


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default import batch file to excel

You only give the file name, not the path. Without a path Excel will look
for the file in the current directory (hint: do a File... Open from the Excel
menu, look at the folder it is opening: that is where it is looking for your
file). Ty specifying the entire path, e.g.
Workbooks.OpenText Filename:="C:\MyStuff\FileFolder\batch.BAT",...
--
- K Dales


"TxRaistlin" wrote:

Hi all,

Using Excel2002, trying to open a batch file and copy to another sheet
within a workbook, however I am getting a file not found error, even though
it is definitely there. Any suggestions?

Sub import_batch()

Workbooks.OpenText Filename:="batch.BAT", Origin _
:=xlWindows, startrow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=False, Space:=True, other:=False, FieldInfo:=Array(1, 1)

Workbooks("batch.BAT").Activate
Range("a1", Range("a1").End(xlDown).End(xlToRight)).Copy
ThisWorkbook.Activate
JumperInput.Activate
ActiveSheet.Paste Destination:=Worksheets("JumperInput").Range("a1")
Application.CutCopyMode = False
Workbooks("batch.BAT").Close SaveChanges:=False


End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to import SQL databases automatically / by batch? Simon Kwong Excel Discussion (Misc queries) 1 August 2nd 09 07:44 PM
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
Run a batch file from Excel Tempy Excel Programming 7 May 18th 05 01:41 PM
batch import dat files The Real Jd Excel Discussion (Misc queries) 2 February 16th 05 12:35 PM
Create a batch file from a number of Excel File Vinay[_2_] Excel Programming 0 September 8th 04 01:11 AM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"