Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 45
Default Saving a workbook with a makro

I am writing a macro, a part of which is saving the current workbook. I dont
want the name of the file to be the same everytime... The path name should
stay the same but the name of the file should be taken from a cell in the
workbook (C5).

How can I write this into the macro?

ActiveWorkbook.SaveAs Filename:= _
"P:\***path name***\Name of the file.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Thanks for any help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Saving a workbook with a makro

Hi,

Set the variable mypath to the correct one and change Sht to the correct
worksheet and try this

mypath = "C:\"
Set sht = Sheets("Sheet1")

ActiveWorkbook.SaveAs Filename:= _
mypath & sht.Range("C5").Value _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Wombat" wrote:

I am writing a macro, a part of which is saving the current workbook. I dont
want the name of the file to be the same everytime... The path name should
stay the same but the name of the file should be taken from a cell in the
workbook (C5).

How can I write this into the macro?

ActiveWorkbook.SaveAs Filename:= _
"P:\***path name***\Name of the file.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Thanks for any help

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Saving a workbook with a makro

Edit the sheetname.....

Dim strPath as String
Dim strFile as String

strPath = ActiveWorkbook.Path
strFile = Sheets("Sheetname").Range("C5").Text & ".xls"

ActiveWorkbook.SaveAs Filename:= strPath & "\" & strFile, FileFormat:=xlNormal

--
Jacob


"Wombat" wrote:

I am writing a macro, a part of which is saving the current workbook. I dont
want the name of the file to be the same everytime... The path name should
stay the same but the name of the file should be taken from a cell in the
workbook (C5).

How can I write this into the macro?

ActiveWorkbook.SaveAs Filename:= _
"P:\***path name***\Name of the file.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Thanks for any help

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
Makro Fredrik New Users to Excel 2 May 6th 09 06:38 PM
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Makro in excel Ted Excel Worksheet Functions 6 June 28th 06 02:06 PM
If with a makro Tove Excel Discussion (Misc queries) 1 April 12th 05 01:49 PM
Makro Esrei Excel Discussion (Misc queries) 1 March 1st 05 12:34 PM


All times are GMT +1. The time now is 11:58 PM.

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

About Us

"It's about Microsoft Excel"