Results 1 to 4 of 4

Thread: Open Excel file and save as .xlsx using VB code

  1. #1
    Join Date
    Feb 2009
    Posts
    56

    Open Excel file and save as .xlsx using VB code

    hello,

    I want to implement a VB macro code in which Excel 2007 is set to open the Excel files and save all of them as .xslx files.
    Does anybody have an information regarding this. How can I implement the required VB macro code ?
    any ideas.....kindly suggest
    thnx

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Open Excel file and save as .xlsx using VB code

    Consider the following code below. This code stores the filename the user returns in the public variable Fname. If the file is already open, then the sub will not open the file again and if the user cancels the filename procedure then the sub exits

    Code:
    Public Fname
    
    Sub OpenF()
        Dim wb As Workbook
        Fname = Application.GetOpenFilename("Excel-files,*.xls", , "Please open your file")
        'no file selected
        If Fname = False Then Exit Sub
        For Each wb In Application.Workbooks
            If wb.Path & "\" & wb.Name = Fname Then
                MsgBox "File " & wb.Name & " is already open"
                Exit Sub
            End If
        Next
        Workbooks.Open (Fname)
    End Sub

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: Open Excel file and save as .xlsx using VB code

    Click Here -

    Use VBA SaveAs in Excel 2007

    You will find the useful vb macro code that will help you to serve the required purpose.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Open Excel file and save as .xlsx using VB code

    If you have Excel 2007, you could save the Excel file as xlsx format, which does not save macros. You can then re-save as xls for compatibility if you want to.

Similar Threads

  1. Troubleshooting “Can’t open .xlsx file” in Vista
    By Bretharm in forum Windows Software
    Replies: 6
    Last Post: 22-02-2012, 10:16 AM
  2. Replies: 2
    Last Post: 15-02-2012, 08:14 PM
  3. Can not open file "Xlsx" with excel 2007
    By Bassus45 in forum Windows Software
    Replies: 16
    Last Post: 10-02-2012, 07:59 AM
  4. Replies: 3
    Last Post: 23-01-2011, 08:22 PM
  5. Excel files file1.xlsx file2.xlsx not found
    By Sachit in forum Windows Software
    Replies: 3
    Last Post: 05-06-2009, 11:50 PM

Tags for this Thread

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
  •  
Page generated in 1,713,439,545.23892 seconds with 17 queries