+ Reply to Thread
Results 1 to 2 of 2

Error trying to close down dbase IV file used for input to excel

  1. #1
    don
    Guest

    Error trying to close down dbase IV file used for input to excel

    I am getting errors trying to close down a dbase file.
    In the code below:
    at the line Windows(filename).activate
    I get a Run-time error '9' subscript out of range.
    I think that is because windows only works on .xls files but that is
    only a guess on my part.
    at the line Filename.Delete
    I get a run-time error '424' subscript out of range.
    I beleive somehow I need to close the file before deleting it.
    Thanks in advance for any help.
    Don


    Workbooks.Open Filename:="C:\My Documents\export.dbf"
    Filename = "C:\My Documents\export.dbf"
    ' do stuff here
    Application.DisplayAlerts = False
    Windows(Filename).Activate ' Close down imported file before exiting
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    Filename.Delete

  2. #2
    Dave Peterson
    Guest

    Re: Error trying to close down dbase IV file used for input to excel

    Windows(Filename).Activate

    Can't have the path included:

    Filename = "export.dbf"
    Windows(Filename).Activate

    may work ok.



    don wrote:
    >
    > I am getting errors trying to close down a dbase file.
    > In the code below:
    > at the line Windows(filename).activate
    > I get a Run-time error '9' subscript out of range.
    > I think that is because windows only works on .xls files but that is
    > only a guess on my part.
    > at the line Filename.Delete
    > I get a run-time error '424' subscript out of range.
    > I beleive somehow I need to close the file before deleting it.
    > Thanks in advance for any help.
    > Don
    >
    > Workbooks.Open Filename:="C:\My Documents\export.dbf"
    > Filename = "C:\My Documents\export.dbf"
    > ' do stuff here
    > Application.DisplayAlerts = False
    > Windows(Filename).Activate ' Close down imported file before exiting
    > ActiveWorkbook.Close
    > Application.DisplayAlerts = True
    > Filename.Delete


    --

    Dave Peterson

+ 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