Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-06-2009
Member
 
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
Reply With Quote
  #2  
Old 11-06-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
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
Reply With Quote
  #3  
Old 11-06-2009
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #4  
Old 11-06-2009
Member
 
Join Date: May 2008
Posts: 2,008
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Open Excel file and save as .xlsx using VB code"
Thread Thread Starter Forum Replies Last Post
Troubleshooting ?Can?t open .xlsx file? in Vista Bretharm Windows Software 6 22-02-2012 10:16 AM
Microsoft Excel fails to open .xlsx file after installing compatibility pack Sreedharna MS Office Support 2 15-02-2012 08:14 PM
Can not open file "Xlsx" with excel 2007 Bassus45 Windows Software 16 10-02-2012 07:59 AM
Microsoft Excel 2010: Unabel to set default program for .xlsx file Rufta Windows Software 3 23-01-2011 08:22 PM
Excel files file1.xlsx file2.xlsx not found Sachit Windows Software 3 05-06-2009 11:50 PM


All times are GMT +5.5. The time now is 04:21 AM.