Use the VBA SaveAs Method in Excel FileFormat Case FileExtStr = “. xlsx”: FileFormatNum = 51 Case roject Then. I have just started looking at code saving in vba and I am sure this will seem like a stupid question to a lot of you out there. After reading a. Note: This method has been added to the Excel object model with Excel and requires the Save as PDF or XPS Add-in for Microsoft Office programs to.

Author: Goltimi Goshakar
Country: Bermuda
Language: English (Spanish)
Genre: Automotive
Published (Last): 15 June 2004
Pages: 470
PDF File Size: 18.38 Mb
ePub File Size: 2.19 Mb
ISBN: 365-7-19391-927-1
Downloads: 41112
Price: Free* [*Free Regsitration Required]
Uploader: Shakazilkree

ExportAsFixedFormat, but I can’t get it to work properly. Email Required, but never shown.

The time now is This website uses cookies, including third party ones, to allow for analysis of how people use our website in order to improve your experience and our services. You can use this macro in Excel Stack Overflow works best with JavaScript enabled.

Use the VBA SaveAs Method in Excel – Microsoft Blog

Force SaveAs with macro-enabled sheet Thank you! Name Then With Application. I need to be able to understand this since I’m sure it’s only going to fileformstnum more complicated from here.

I’m the only one here at my job with any knowledge of programing and they want me to do everything for them. All times are GMT But because there are so many new file formats in Excelwe shouldn’t use code like this that does not specify the FileFormat parameter. Example 1 you can use in ExcelExample 2 you can use in Excel Excellent – though I found the last parameter to have another name OpenAfterPublish. Ron de Bruin Excel Automation. I did this in Word, and the format number is Login or Sign Up.


The code you’ve posted is simply creating a copy of the source worksheet not the entire workbookthen saving the copy to a different folder with a new name and deleting it after sending the email. Thread Tools Show Printable Version. Lounge Office Applications Visual Basic for Apps I need help tweaking vba code that sends one sheet from excel via outlook.

I’ve given up though. I always use the FileFormat numbers instead of the defined constants in my code so that it will fileormatnum OK when I copy the code into an Excel workbook.

Examples Below are two basic code examples to copy the ActiveSheet to a new Workbook and save it in a format that matches the file filefoormatnum of the parent workbook.

Force SaveAs with macro-enabled sheet October 21st, In ExcelSaveAs requires you to provide both the FileFormat parameter and the correct file extension.


By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued use of the website is subject to these policies.

Part of Projects. You see a lot of old SaveAs code that does not specify the FileFormat parameter. Force SaveAs with macro-enabled sheet try That said, your code could be filefor,atnum and made more efficient.

This works so well that it always saves as the calculated file name. Paul Mendoza 3, 8 42 If you run the code in Excelit will look at the FileFormat of the parent workbook and save the new file in that format. An example of the excel file format numbers can be found here.


All times are GMT Post as a guest Name. By continuing to use our website, you agree to the filefor,atnum of such cookies. Results 1 to 2 of 2. Name, InStr 1, wb. Only if the parent workbook is an xlsm file and if there is no VBA code in the new workbook it will save the new file as xlsx. Maybe there’s nothing that I’m setting it to? How can I be notified when my favorite forums contain new threads? How should I configure my browser to get the greatest benefits from the Lounge?

The above FAQ links open in a new window. Excle SaveAs with macro-enabled sheet Thanks for all your help but I have another question.

Use the VBA SaveAs Method in Excel 2007

I know saving files as a PDF works much better with. In Excel versions before Excelcode without this parameter will not cause too many problems because Excel will use the current FileFormat of the existing file and the default FileFormat for new files is a xls in because there are no other Excel file formats before Excel Last edited by macropod; at Forums Blogs Articles Groups.

I keep getting the error message: The only issue I am having is with saving the selection as a PDF. The time now is The issues i’m facing are: For additional details, refer to our Privacy Policy.