View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.

"Tom Ogilvy" wrote:

sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

where cell B9 contains the name you want.

------------------

if you want the path in B8 and the name in B9

sPath = Range("B8").Value
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

------------------


If you want to save in the same location as the activeworkbook currently is
located

sPath = ActiveWorkbook.Path
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom;
I am looking to have the file name be what ever I enter into cell B9.
Thanks

"Tom Ogilvy" wrote:

if B9 contains the string C:\Temp\MyFile.xls

then C:\Temp\ is the file path.

The activeworkbook is saved to the C:\Temp directory with a filename of
MyFile.xls
--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value

where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell

entered
in
the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would

like
to
be
able
to do this by assiging a macro to a button.