Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Update - Include cell contents in filename automatically
Thanks to grinning_crow for this post telling me how to automatically
include contents of a cell in a filename when saving: As far as I know there are two things you could do; This would simply save the file automatically and not give them a chance to change the name, adding the contents of cell A1 to the end of your specified string: sub workbook_beforeclose(cancel as integer) activeworkbook.saveas "Field Rating - " & sheet1.range("A1") end sub It's not working yet; I get the following error: Compile Error: Procedure declaration does not match description of event or procedure having the same name Additionally, this Sub uses the BeforeClose method (terminology?) so it only activates when the user tries to close the workbook; I'd like it to happen when they try to "Save" or "Save As...." I tried substituting the BeforeSave method instead but it produced the same error on "Save" or "Save As..." actions. The section of code highlighted on the error was the following: Private Sub Workbook_BeforeSave(Cancel As Integer) Don't think it's related, but I changed the cell reference to C3 since that's where the customer name lives and that's what I'd like this sub to pull into the filename. C3 is a merged cell, if that makes any difference. Any direction is appreciated...I feel like I'm so close! Bryan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Update - Include cell contents in filename automatically
when entering an event, you should select the event from the dropdowns at
the top if the module. then the event will be entered properly rather than improperly as you show - which causes the error you describe. You can learn about events at Chip Pearson's site: http://www.cpearson.com/excel/events.htm -- Regards, Tom Ogilvy "Bryan Linton" wrote in message ... Thanks to grinning_crow for this post telling me how to automatically include contents of a cell in a filename when saving: As far as I know there are two things you could do; This would simply save the file automatically and not give them a chance to change the name, adding the contents of cell A1 to the end of your specified string: sub workbook_beforeclose(cancel as integer) activeworkbook.saveas "Field Rating - " & sheet1.range("A1") end sub It's not working yet; I get the following error: Compile Error: Procedure declaration does not match description of event or procedure having the same name Additionally, this Sub uses the BeforeClose method (terminology?) so it only activates when the user tries to close the workbook; I'd like it to happen when they try to "Save" or "Save As...." I tried substituting the BeforeSave method instead but it produced the same error on "Save" or "Save As..." actions. The section of code highlighted on the error was the following: Private Sub Workbook_BeforeSave(Cancel As Integer) Don't think it's related, but I changed the cell reference to C3 since that's where the customer name lives and that's what I'd like this sub to pull into the filename. C3 is a merged cell, if that makes any difference. Any direction is appreciated...I feel like I'm so close! Bryan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Insert a filename that will automatically update if changed. | Excel Worksheet Functions | |||
Cell("filename") doesn't update to new filename when do save as. | Excel Worksheet Functions | |||
Macro to include contents of cell | Excel Discussion (Misc queries) | |||
Automatically include contents of a cell in "Save As..." filename. | Excel Programming | |||
cell contents as filename | Excel Programming |