Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
How to save file in a macro taking new name from cell contents?
I want to Save-as a file from within a macro, taking the new name from the
worksheet's cell contents. I want to save an order form with a file name based on the order number contained in a worksheet cell. My question is how to get the cell contents into the Save-as dialog box when the macro calls the Save-as function. Thanks. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
How to save file in a macro taking new name from cell contents?
Hi LowIQ,
Try: '============= Public Sub Tester004() Dim sStr As String sStr = ThisWorkbook.Sheets("Sheet1"). _ Range("A1").Value '<<=== CHANGE ThisWorkbook.SaveAs Filename:=sStr & ".xls", _ FileFormat:=xlWorkbookNormal End Sub '<<============= --- Regards, Norman "LowIQ" wrote in message ... I want to Save-as a file from within a macro, taking the new name from the worksheet's cell contents. I want to save an order form with a file name based on the order number contained in a worksheet cell. My question is how to get the cell contents into the Save-as dialog box when the macro calls the Save-as function. Thanks. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
How to save file in a macro taking new name from cell contents?
Assuming your order number is in cell A1,
ActiveWorkbook.SaveAs Filename:=cells(1, 1).value & ".xls" -Simon "LowIQ" wrote: I want to Save-as a file from within a macro, taking the new name from the worksheet's cell contents. I want to save an order form with a file name based on the order number contained in a worksheet cell. My question is how to get the cell contents into the Save-as dialog box when the macro calls the Save-as function. Thanks. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
How to save file in a macro taking new name from cell contents?
I have used the following technique quite a bit. the ActiveWorkbook.FullName returns the active workbook name and path; e.g. C:\My Documents\MyName\MyBook.xls Private Sub SaveInvoiceNo () dim myInvoiceName as string, myNumber as String myNumber = Worksheets("Invoice").Range("E1").Value myInvoinceName = ActiveWorkbook.FullName myInvoiceName = Left(myInvoiceName, Len(MyInvoiceName) - 4) myInvoiceName = myInvoiceName & "_" & mynumber & ".xls" ActiveWorkbook.SaveCopyAs Filename:=myInvoiceName end sub -- DCSwearingen Getting old, but love computers. ------------------------------------------------------------------------ DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506 View this thread: http://www.excelforum.com/showthread...hreadid=547247 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Compiling macro based on cell values | Excel Discussion (Misc queries) | |||
macro save a file name from a cell in 1st worksheet | Excel Discussion (Misc queries) | |||
Using "Save As" with a file name selected by cell | Excel Discussion (Misc queries) | |||
Macro to remove contents of cell and move all other contents up one row | Excel Discussion (Misc queries) | |||
This one is tricky....Macro to save file as cell value x in di | Excel Discussion (Misc queries) |