VBA Script - How To Save Worksheet As XLSX
Nov 5, 2013
In my script below it saves each tab in Excel as a separate worksheet and titles the file the same as the tab name.
Is there a way to make it save as an .xlsx ***e unstead of a .xls file?
Dim wks As Worksheet
Dim newWks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
wks.Copy 'to a new workbook
Set newWks = ActiveSheet
With newWks
[Code]...
View 3 Replies
ADVERTISEMENT
Aug 21, 2012
What I am trying to do is that I have an excel file with macros and it is a read-only file. In order for the user to save, I want them to only be able to save as a .xlsx file as it disables all macros. If for whatever reason, the user wants to save the file as another .xlsm file, they should be allowed but before they save, a "are you sure you want to save as .xlsm?" message should pop up.
All the options in the save as box should still be available in case they want to save in that particular format. Just that the .xlsx should be the default.
View 2 Replies
View Related
Jan 31, 2012
I got this code:
Sub CopyTotals()
Dim wsTotals As Worksheet
Dim SaveFolder As String, CurrentDate As String, D3Content As String
Set wsTotals = Worksheets("totals")
[Code] ........
what should i add/change in order to save the file as a PDF file instead of XLSX file?
View 4 Replies
View Related
Aug 13, 2013
I am currently using some of Mr. Excels macro coding to firstly create consecutive invoice numbers and secondly save the new file into a destination folder and clear out the cells that have had data in them. This part seems to work flawlessly. I have noticed though that the new .xlsx file has the macro buttons viewable on it and to me looks unprofessional if i send out an invoice to a customer that has the buttons shown. So my resolution is to export the file as a PDF rather than the .xlsx.
My code is as follows
Code:
Sub NextInvoice() Range("H13").Value = Range("H13").Value + 1
Range("B24:H43").ClearContents
End Sub
Sub SaveInvWithNewName()
Dim NewFN As Variant
' Copy Invoice to a new workbook
[Code] .......
View 2 Replies
View Related
Mar 12, 2014
How can I save worksheet from existing workbook as a new workbook with extension .xls or .xlsx depending on the version of Excel on which the original was opened and no matter the extension of original?
My code that I was trying to create all above does not work, because even if I am using Excel 2007, 2010 or 2013 it will still be saving only as .xls.
View 2 Replies
View Related
Mar 11, 2014
am using Excel 2010 and having issues trying to save a worksheet to a specified file location with the save date....
I have tried several posts form this forum and elsewhere and can't seem to get the macro to do what I want.....
I want to save a 'worksheet' from an open workbook that I use for updating information to the same file path as the workbook with the date the file saved...
View 6 Replies
View Related
Apr 19, 2009
I have just received an eMail from my accountant and here file name extension is .xlsx. I have never seen this before. Can someone tell me why the x on the end of the extension? . Also, when it opens, a Message Box is displayed: File Conversion in process.
View 4 Replies
View Related
Oct 9, 2009
how to convert .xlsx file into .csv?
View 4 Replies
View Related
Oct 21, 2013
I am facing this error problem in my laptop. Error: Excel can't open the file (name).xlsx because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of file.
When every i am trying to open all the excel files are giving me this error. I try many software and change the extension. But no result. Same error message is coming. Really if its not fixed i will lose too much important data.
View 1 Replies
View Related
Dec 31, 2008
I have to download files from a database and save them in .xls format (the only format permitted to export from the database)
Given an open excel wb saved to my hard drive (or network drive) in non .xlsx format. (most likely .xls)
Switch the file to .xlsx format without loosing the open file. (re-open ok).
Caveats:
-Don't want two files
-Dnn't want to have the file name changed (except for the extension).
-Don't want to remain in compatibility mode.
-Don't want to wait a long time.
-Don't want to have possibility of file corruption.
I just want to take my non .xlsx file and then, turn into a .xlsx file. (if I save the file as .xlsx I am still in compatibility mode until I re-open the file. I also will have two files---very annoying).
View 9 Replies
View Related
Jul 21, 2009
Using Excel 2007:
I am trying to use dir() in a While...wend to get a specific list of files to process, but I want the list to only include those with a .xls extension, not those ending in .xlsx. It seems that the file filter ".xls" doesn't exclude those files with a ".xlsx" extension.
Sample code demonstrating the problem (will show the problem if there is at least one cycle that meets a*.xls and one that meets a*.xlsx).
Is there a workaround to this at the dir() level? Or do I need to go ahead and open the file and test its contents?
Sub TestDir()
On Error GoTo Nofile 'trap cancel, X-out of the dialog, etc.
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "a*.xls"
.Show
GetDir = .SelectedItems(1)
End With
On Error GoTo 0 'reset error handler
View 9 Replies
View Related
Apr 5, 2012
I'm having some troubles sending email as attachments from Excel using VBA where my workbooks have the XLSX name. I am getting the following message instead of the email with attachments:
FILE QUARANTINED
The original contents of this file have been replaced with this message because of its characteristics.
File name: 'winmail.dat'
Virus name: 'ScanTimeExceeded'
When I change the file extension to xls it is fine - I get the attachments on the email.
Here is my VBA:
With oLookMail
'.To = "busmgrs2@uwc.edu"
'.CC = "finspec2@uwc.edu"
.To = msToRecip
.Subject = "Accounts Status Reports as of " & msAsOfDate
.Body = "Attached are the AR Monthly Reports"
.Attachments.Add "citpfile07usoffAccounts ReceivableAR Monthly Report 2004-05.xlsx"
[Code]....
View 4 Replies
View Related
May 3, 2014
I've got several huge information bloks to handle.
Would you be so kind as to give the matter a reasonable consideration?
I've added an xlsx file with more detailed description.
View 1 Replies
View Related
Oct 2, 2013
how to run my Macro over multiple (about 60) .xlsx files. I have been looking around, but haven't quite got anything working yet.
I have all the files in the same folder with similar names (i.e. Subject_01.xlsx, Subject_02.xlsx, etc.).
What I'd like is:
*open Subject_01
*run script (some calculations, copy/pasting, my script for this is working fine)
*save file under a different name (i.e. Subject_01_processed.xlsx)
*close file
*again for Subject_02, Subject_03, etc.
Additionally, I have a second question: after I have the processed .xlsx files, I'd like to copy some cells from each .xlsx file (e.g. A1-H1) to a new file. There, I'd like the data from Subject_01 to for example be in cells A1-H1, from Subject_02 in cells A2-H2, etc.
View 5 Replies
View Related
Apr 22, 2014
I am using the following code to open a woorkbook:
Workbooks.Open Filename:= "C:UsersDesktopExcel.xlsx"
I am running into an issue were a file may be saved as .xls or .xlsm instead, but I still need to have the macro open it. Is there a way to adjust the above code, or other code for that matter, that will allow my macro to open any of these extensions?
View 3 Replies
View Related
Jun 23, 2014
I have a master workbook that contains macros and has an xlsm extension.
One macro in the workbook copies one of the worksheets to a new workbook. I then want to save this new workbook as an xlsx file. I use the following code line:
.SaveAs Filename:=Extract_Save_Name & ".xlsx", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
However, when I run the code I get an error:
"This extension cannot be used with the selected file type."
The new workbook does not contain any macros and if I save the workbook "manually" as an xlsx it saves fine.
If I change the code above to have "xlsm" it works fine - but I don't want that extension.
View 1 Replies
View Related
Dec 19, 2012
I have attempted to alter this example to simply check if the cells are not blank by replacing the "X" with "<>", but I get errors in the SMALL function--it looks like the IF statement is just returning an array with all of the values set to FALSE, and none of the values in the array call out a location of the next filled cell.
How could you alter your fixed XLSX file to check for non-blank cells instead of "X" specifically?
View 2 Replies
View Related
Sep 10, 2009
When I prepare a file with macro's (to be used by other people), I save this file as a template with macro's with the extension *.xltm (template with macro).
Therefore no one can overwrite my file. These other people can open this template (e.g. double-click, but not file-open). But when these people save this file, Excel automatically saves it as a normal Excel-file with the extension *.xlsx.
Ok, a message is seen after pressing <enter> or clicking Save, but does normal users know, what they have to do then?
If I'm making a template with macro's, I want Excel to have this file saved as a file with macro's. Whatever did I make a file with macro's for? Is this a bug or is it done on purpose?
View 3 Replies
View Related
Jul 25, 2009
I was able to get some code to save an existing worksheet to a new workbook. However, when a duplication file name exists it prompts me to save as and if I click 'No' I get a debug error message. I'd still like the 'save as' message to come up but is there a way I can get eliminate the debug error message if 'No' is clicked?
View 3 Replies
View Related
Apr 2, 2014
I have created a user form (UserForm1). When I click the submit button I would like (after it has completed various other commands) it to save a worksheet "Invoice" as a PDF.
I know this is possible, however, I would like the filename to be pulled from:
A field from the UserForm1 we will called "PlotID", and a cell I have created that displays the current year and quarter, on the "Invoice" sheet "U12".
So the file created would be called "Invoice - [PlotID] [U12].pdf"
View 8 Replies
View Related
Mar 24, 2012
Description:The chart shown in the file is a picture using the Camera Tool. The real chart is in the worksheet "Chts". When using the dropdown & radio button, the chart is supposed to change accordingly.
Problem 1:The picture from the camera tool seem to be blurry. The lines also seem thicker. Any rectifications for this?
Problem 2:If I save this file as "xlsx", the chart will not change dynamically when the dropdown is changed.
2003 version
[URL]
2007 version
[URL]
View 6 Replies
View Related
Mar 26, 2014
I need to convert some xlsx files into CSV, but they contain the following foreign languages -
Polish
Czech
Romanian
Hungarian
When saving these files as CSV many of the unique characters get changed to a ?
I have tried a few things like using Open Office and saving it as a text CSV and then adjusting the formatting to unicode 8 but it hasn't worked. i am using Excel 2013?
View 3 Replies
View Related
May 8, 2014
I have a sheet full of data.All this long I had written the code to save the selected cells as a PDF.But now I want it to be saved as a separate file. In this case, I believe, first the VBA will have to open a new workbook. Then copy paste this sheet onto one of the sheets in the workbook . then save the .XLM file.
[Code] ..
View 7 Replies
View Related
Dec 30, 2008
Is it possible to have the worksheet save itself automatically every 5 minutes or so?
I don't want the user to have to click on a macro or do anything. Basically they will not even know that it is saving.
View 2 Replies
View Related
Apr 21, 2012
My workbook has a worksheet for reports of sales by each sales person (which I had hoped to send by email). CDO didn't work because I have win7 and no flavors of Outlook and ShellExecute worked but truncated any sales beyond the first dozen. So.... My NEXT plan is to include a SAVEAS pdf for that report worksheet (with 12 or more reccords) using the salesperson's name and saving them all in a reports folder. Then I will go back and manually send those reports as attachments.
View 1 Replies
View Related
Jul 7, 2014
As a newbie to macros I am having trouble trying to save a worksheet to CSV file. The macro worked to .txt but when I change it to .xlCSV it comes up with runtime 1004 error, method 'save as' of object '_workbook' failed.
Sub Export7400_setup_Click()
'
' Exportsub Macro
'
Dim sPath As String
Dim FName As String
FName = Range("rng7400Filename")
sPath = Range("strWorksheetPath")
[Code]...
View 3 Replies
View Related
Apr 19, 2007
I have a save button on a user form that saves a workbook
Private Sub SaveBookbtn_Click()
' SaveAs using data from workbook cells
Dim ThisFile As String
Dim TheFilename As String
ThisFile = Sheets("Sheet1").Range("A2").Value
TheFilename = Application.GetSaveAsFilename _
(ThisFile, filefilter:="Excel Files, *.xls")
If TheFilename = "False" Then Exit Sub
ThisWorkbook.SaveAs TheFilename
ThisWorkbook.Close
End Sub
But what I would like to do is save just "sheet1", and not the whole workbook, using ThisFile as the name to save it under - where I can choose which directory it can go in. I have tried to modify the code to get the desired results but I can't seem to crack it. Can the above code be modified to do the job or am I going to have to start from scratch?
View 2 Replies
View Related
Feb 12, 2014
I am trying to take the template I have created and after the information is entered, if all required is not filled in, it will highlight the cells that need filled in. I get a debug error on
VB:
Cell.Interior.ColorIndex = 6
And the file does not save elsewhere. It goes into never never land. Here is my whole code:
VB:
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Start As Boolean
[Code]....
View 5 Replies
View Related
Jan 31, 2010
Is there a way to export and save the contents and table layout of a worksheet as a picture ( say jpeg )?
Basically what I would love to do is that when I save the workbook, a certain worksheet named " Fax " is saved to my desktop as a picture (as a snapshot). What would even be better is that the said file was named with simply the date !
The purpose of this is so I can email it to a very non computer guy who thinks that excel is only a gum . . .
I know this is weird but you guys are the best, you helped me a lot to make my spreadsheet.
View 14 Replies
View Related
Jun 26, 2014
I have the following code in VB from somewhere. How to modify or adding from the following codes.
(1) Is anyway I can modify sedning out PDF instead of the actual workbook?
(2) Is anyway I just want the range from (A1:G80) instead of the whole sheet for printing (PDF).
View 3 Replies
View Related