+ Reply to Thread
Results 1 to 3 of 3

Problem saving file as .csv

Hybrid View

  1. #1
    Registered User
    Join Date
    07-04-2016
    Location
    Santiago, Chile
    MS-Off Ver
    2010
    Posts
    2

    Problem saving file as .csv

    I need to save some sheets in the workbook as .cvs.
    When I do it manually it saves the file as .cvs and when I open the file it shows the data in columns but when i do it with a macro it saves the file as .cvs but when I open the files it shows the columns in one column with commas as separator.

    This is my code so far:
    Sub Crea_Libros_Cargar()
    ' se encargara de recorrer todas las hojas
    Dim W As Integer
    'variables para las rutas
    
    Dim Nombre, RutaGuardar As String
    Dim Nombresuc As String
    Dim Nombrecd As String
    
    Nombresuc = InputBox("Sucursal")
    Nombrecd = InputBox("CD")
    
        'creo un ciclo for recorriendo todas las hojas del archivo actual
        For W = 1 To ActiveWorkbook.Sheets.Count
                'activo la primera hoja
                Sheets(W).Activate
                'asigno el nombre de la hoja a la variable
                Nombre = ActiveSheet.Name
                Sheets(Nombre).Copy
                
                RutaGuardar = "C:\Users\carolina.urra\Documents\Distribucion\Sugerido Distribucion\MACRO\" & Nombresuc & Nombrecd & Nombre & ".csv"
                '
                
                ActiveWorkbook.SaveAs Filename:=RutaGuardar, FileFormat:=xlCSV, CreateBackup:=False
                
                ActiveWindow.Close Savechanges:=True
        Next
        MsgBox ("proceso finalizado exitosamente") _
    , , "Finalizado"
    End Sub
    Can someone please help me to save the files the same way when I do it manually.

    Here its what I Get when i record the saving process:
        Sheets("1").Select
        Sheets("1").Name = "1"
        Sheets("1").Select
        Sheets("1").Copy
        ActiveWorkbook.SaveAs Filename:= _
            "C:\Users\carolina.urra\Documents\Distribucion\Sugerido Distribucion\MACRO\Libro24.csv" _
            , FileFormat:=xlCSV, CreateBackup:=False
        ActiveWorkbook.Save
        ActiveWindow.Close
    Last edited by carocat; 07-04-2016 at 01:55 PM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Problem saving file as .csv

    Hello carocat,

    Welcome to the Forum.

    Unfortunately, Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    07-04-2016
    Location
    Santiago, Chile
    MS-Off Ver
    2010
    Posts
    2

    Re: Problem saving file as .csv

    I´ve done the code-taging. Hope it meets the requiremnets now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Problem saving ppt file from vba
    By sbe70 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-13-2016, 09:32 AM
  2. [SOLVED] Problem with Saving .csv file as excel file
    By dreindorf in forum Excel General
    Replies: 3
    Last Post: 02-10-2016, 06:59 PM
  3. Problem saving Excel file that copies an embedded object from a separate file
    By bhodge10 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2012, 02:47 PM
  4. Excel file saving problem
    By frulhaque in forum Excel General
    Replies: 1
    Last Post: 06-14-2009, 03:59 AM
  5. Problem saving file
    By ssim in forum Excel General
    Replies: 1
    Last Post: 04-27-2007, 01:41 AM
  6. Problem saving excel file
    By bsimo49 in forum Excel General
    Replies: 4
    Last Post: 08-06-2006, 05:55 PM
  7. problem when saving CSV file
    By mhe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-05-2005, 04:06 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