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

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. K. Rajasekar

    Trapping close...save (yes/no/cancel) thru macro

    K. Rajasekar, Dec 27, 2003, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    121
    Steve Wylie
    Dec 27, 2003
  2. Graham

    Removing carriage returns from a CSV file.

    Graham, Jan 28, 2004, in forum: Word VBA Beginners
    Replies:
    6
    Views:
    194
    Guest
    Jan 31, 2004
  3. jls

    Execute macro on File Save or File Save As

    jls, Jul 21, 2004, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    145
    Jezebel
    Jul 21, 2004
  4. Graig
    Replies:
    4
    Views:
    340
    Jezebel
    Oct 24, 2004
  5. natanz

    populate combobox from csv

    natanz, Jul 20, 2005, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    296
    Doug Robbins
    Jul 20, 2005
  6. Chris Moorhead
    Replies:
    7
    Views:
    290
    Chris Moorhead
    Nov 30, 2005
  7. Jchick

    VB making a CSV from a filename

    Jchick, Mar 17, 2006, in forum: Word VBA Beginners
    Replies:
    1
    Views:
    106
    Jonathan West
    Mar 17, 2006
  8. TriEssent

    Create CSV File

    TriEssent, Sep 28, 2006, in forum: Word VBA Beginners
    Replies:
    7
    Views:
    127
    Graham Mayor
    Sep 29, 2006
Loading...