Results 1 to 2 of 2

Save a worksheet off as it's own CSV without errors.

Threaded View

111StepsAhead Save a worksheet off as it's... 08-08-2013, 09:27 AM
patel45 Re: Save a worksheet off as... 08-08-2013, 11:52 AM
  1. #1
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Save a worksheet off as it's own CSV without errors.

    I am trying to get this code to work without errors and there is one error I cannot get past.

    Sub EXPORT_CSV()
        Dim fPath As String
        Dim wb0 As Workbook
        
        With Application.FileDialog(msoFileDialogFolderPicker)
            .AllowMultiSelect = False
            .Show
            If .SelectedItems.Count > 0 Then
                fPath = .SelectedItems(1) & "\"
            Else
                Exit Sub
            End If
        End With
        
        fname = fPath & "my_file.csv"
        Worksheets("my_file.csv").Copy
        Set wb0 = ActiveWorkbook
        wb0.SaveAs fname
        wb0.Close
    End Sub
    So as long as you have a worksheet named "my_file.csv" then the code works great. It's when I go to open the saved worksheet that I get my first error.

    The file you are trying to open, 'my_file.csv', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

    And I click yes and the file looks correct; I see the one worksheet with the exact same data on the workbook I saved it from.

    Does anyone have any idea what is going on here? Thanks for your help.
    Last edited by 111StepsAhead; 08-08-2013 at 01:21 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. My Word Macro creats Save w/ Errors grrr!
    By DadaaP in forum Word Formatting & General
    Replies: 1
    Last Post: 06-14-2013, 11:56 AM
  2. Save VBA errors & report them after macro completes
    By Philb1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 01:00 AM
  3. Dealing with errors in file save macro
    By tcombest in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2012, 02:43 PM
  4. Macro errors before save of mail merge document
    By pjbassdc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2011, 02:35 PM
  5. Save as Tab delimited file errors
    By askeladd in forum Excel General
    Replies: 2
    Last Post: 03-13-2007, 04:12 PM

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