+ Reply to Thread
Results 1 to 3 of 3

OpenText method not working

  1. #1
    Pflugs
    Guest

    OpenText method not working

    I am automating a text file from Word to Excel. When I try to open the text
    file in Excel from Word using:

    xlApp.Workbooks.OpenText Filename:= _
    wdFile & ".txt", Origin:=437, _
    StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, _
    ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False,
    Comma:=False _
    , Space:=True, Other:=False, TrailingMinusNumbers:=True

    I get an error. If I delete everything except the filename and the origin,
    it works correctly. However, I need to have the file delimited by spaces.
    What is wrong with this?

    Thanks, Pflugs

  2. #2
    Tom Ogilvy
    Guest

    Re: OpenText method not working

    I would guess you are using late binding (GetObject or CreateObject), so
    Try replacing xlDelimited with its value, 1


    xlApp.Workbooks.OpenText Filename:= _
    wdFile & ".txt", Origin:=437, _
    StartRow:=1, DataType:=1, TextQualifier:=xlNone, _
    ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, _
    Comma:=False, Space:=True, Other:=False, _
    TrailingMinusNumbers:=True

    --
    Regards,
    Tom Ogilvy



    "Pflugs" <Pflugs@discussions.microsoft.com> wrote in message
    news:F637E671-6726-4C89-97E1-5F7DA56A17B7@microsoft.com...
    > I am automating a text file from Word to Excel. When I try to open the

    text
    > file in Excel from Word using:
    >
    > xlApp.Workbooks.OpenText Filename:= _
    > wdFile & ".txt", Origin:=437, _
    > StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, _
    > ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False,
    > Comma:=False _
    > , Space:=True, Other:=False, TrailingMinusNumbers:=True
    >
    > I get an error. If I delete everything except the filename and the

    origin,
    > it works correctly. However, I need to have the file delimited by spaces.
    > What is wrong with this?
    >
    > Thanks, Pflugs




  3. #3
    Pflugs
    Guest

    Re: OpenText method not working

    Thanks, Tom. I ended up just rewriting the macro in Excel. The text file
    imported a lot nicer than I thought it would, and I achieved much better
    results. Thanks for your time.

    Pflugs

    "Tom Ogilvy" wrote:

    > I would guess you are using late binding (GetObject or CreateObject), so
    > Try replacing xlDelimited with its value, 1
    >
    >
    > xlApp.Workbooks.OpenText Filename:= _
    > wdFile & ".txt", Origin:=437, _
    > StartRow:=1, DataType:=1, TextQualifier:=xlNone, _
    > ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, _
    > Comma:=False, Space:=True, Other:=False, _
    > TrailingMinusNumbers:=True
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    > "Pflugs" <Pflugs@discussions.microsoft.com> wrote in message
    > news:F637E671-6726-4C89-97E1-5F7DA56A17B7@microsoft.com...
    > > I am automating a text file from Word to Excel. When I try to open the

    > text
    > > file in Excel from Word using:
    > >
    > > xlApp.Workbooks.OpenText Filename:= _
    > > wdFile & ".txt", Origin:=437, _
    > > StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlNone, _
    > > ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False,
    > > Comma:=False _
    > > , Space:=True, Other:=False, TrailingMinusNumbers:=True
    > >
    > > I get an error. If I delete everything except the filename and the

    > origin,
    > > it works correctly. However, I need to have the file delimited by spaces.
    > > What is wrong with this?
    > >
    > > Thanks, Pflugs

    >
    >
    >


+ 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