Results 1 to 4 of 4

Export sheet to CSV then resave workbook

Threaded View

bossier330 Export sheet to CSV then... 07-14-2010, 10:51 AM
JBeaucaire Re: Export sheet to CSV then... 07-14-2010, 11:18 AM
snb Re: Export sheet to CSV then... 07-14-2010, 11:21 AM
bossier330 Re: Export sheet to CSV then... 07-14-2010, 12:11 PM
  1. #1
    Registered User
    Join Date
    07-14-2010
    Location
    Louisiana, US
    MS-Off Ver
    Excel 2007
    Posts
    2

    Export sheet to CSV then resave workbook

    I have quite an interesting problem. I have an XLSM spreadsheet with an Auto_Open macro that imports data from a CSV file and does some deletion/formatting. It then saves that sheet back over the existing CSV file. I then want to resave the workbook over the existing XLSM file. If Excel 2007 is closed before the macro runs, I get "Runtime error '1004': Cannot access 'Computer Name Listing.xlsm'". However, if I run the Auto_Open macro with the workbook already open, the problem does not happen. Any ideas? The problematic section of my code is below.

        Application.DisplayAlerts = False
        Dim oldName As String, oldPath As String, oldFormat As XlFileFormat
        With ActiveWorkbook
            oldName = .Name
            oldPath = .Path
            oldFormat = .FileFormat
            .ActiveSheet.SaveAs Filename:="bla bla\Names.csv", FileFormat:=xlCSVWindows
            .SaveAs Filename:=oldPath + "\" + oldName, FileFormat:=oldFormat
        End With
        Application.DisplayAlerts = True
    If I enter debugging mode, the error line is the ".SaveAs Filename..." line.

    Thanks for your help.
    Last edited by bossier330; 07-14-2010 at 12:16 PM.

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