View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bryan Linton Bryan Linton is offline
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