Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert a filename that will automatically update if changed. JR Excel Worksheet Functions 1 November 17th 08 02:48 PM
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
Macro to include contents of cell Matt Excel Discussion (Misc queries) 1 November 15th 05 03:51 AM
Automatically include contents of a cell in "Save As..." filename. Bryan Linton Excel Programming 1 September 1st 04 12:14 PM
cell contents as filename Jeff R Excel Programming 1 August 26th 04 03:02 PM


All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"