View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Richard Buttrey Richard Buttrey is offline
external usenet poster
 
Posts: 296
Default Setting file names

On Thu, 7 Jul 2005 15:14:02 -0700, "paulu"
wrote:

Is it possible to create a macro that saves a file and inserts a file name
which is a combination of the contents of two or more cells on the worksheet.
What I am aiming to do is have a button on a toolbar which will run such a
macro and save a sheet as a pdf document with a name which is a combination
of the contents of two or more cells on the worksheet.


I don't know how you can save a worksheet as a .pdf file since pdf
doesn't appear to be a valid file type in Excel. However you can save
a particular worksheet from a workbook by first copying the contents
of the worksheet to a new workbook, then, assuming A1 contains
"Myfilepart1" and A2 contains "Myfilepart2" - (the two cells
containing your required filename), and with the new workbook as the
active workbook

Use

ActiveWorkbook.SaveAs filename:=Range("a1")&range("a2")

in your code.

Rgds
__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________