+ Reply to Thread
Results 1 to 2 of 2

import batch file to excel

  1. #1
    TxRaistlin
    Guest

    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. #2
    K Dales
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1