macro to save .csv in excel 2007 .xlsx format

Discussion in 'Word VBA Beginners' started by Martin, Apr 8, 2010.

  1. Martin

    Martin Guest

    Hi everybody,

    I am putting together a macro that requires saving a .csv spreadsheet to
    Excel format (.xlsx).

    The file has always the same structure but the name changes according to the
    date (it's a download from a customer Portal).

    The code for this section looks like this:

    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and
    Settings\x132476\Desktop\PCIMerchantReport-20100407.xlsx", _
    FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

    Is there a way to save it without refering to the actual filename?

    Any help is appreciated...

    Martin
     
    Martin, Apr 8, 2010
    #1
    1. Advertisements

  2. You are in the wrong forum as this one is for Word.

    However, the code that you need is:

    With ActiveWorkbook
    .SaveAs Left(.FullName, InStr(.FullName, ".")) & "xlsx", _
    FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    End With


    --
    Hope this helps.

    Please reply to the newsgroup unless you wish to avail yourself of my
    services on a paid consulting basis.

    Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

    "Martin" <> wrote in message
    news:D...
    > Hi everybody,
    >
    > I am putting together a macro that requires saving a .csv spreadsheet to
    > Excel format (.xlsx).
    >
    > The file has always the same structure but the name changes according to
    > the
    > date (it's a download from a customer Portal).
    >
    > The code for this section looks like this:
    >
    > ActiveWorkbook.SaveAs Filename:= _
    > "C:\Documents and
    > Settings\x132476\Desktop\PCIMerchantReport-20100407.xlsx", _
    > FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    >
    > Is there a way to save it without refering to the actual filename?
    >
    > Any help is appreciated...
    >
    > Martin
     
    Doug Robbins - Word MVP, Apr 8, 2010
    #2
    1. Advertisements

  3. Martin

    Eric Moore

    Joined:
    May 1, 2015
    Messages:
    1
    Likes Received:
    0
    Wow Doug Robbins this may be the wrong place, but it is the first place I found a real answer.
     
    Eric Moore, May 1, 2015
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.