Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Saving the Active Workbook

I need some help saving files during a macro:

1) I want to specify a path & file name for the active file to be saved
with - no user intervention required. The following code works for the file
name but location seems random - how do I specify where the file should be
saved?

ActiveWorkbook.SaveAs Filename:="my new file.xls"

2) I want to end my macro by having the user save the active workbook with
location and file name of their choice. I have used the following code to
display the SaveAs dialog but when the user clicks Save, the file is not
actually saved. What extra code is needed to execute the Save using location
& file name from the SaveAs dialog?

Application.FileDialog(msoFileDialogSaveAs).Show


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Saving the Active Workbook

Lynn

1) You need to specify the path. For example if you want the file to alway
save to the C drive in a folder called MyWorkbooks then your code should be
as follows:

ActiveWorkbook.SaveAs Filename:="C:\MyWorkbooks\my new file.xls"

2) That line of code only gets the filepath/name. It does not save the
file. Use the following:

FileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Office Excel Workbook (*.xls), *.xls")
If FileSaveName = False Then End
ActiveWorkbook.SaveAs Filename:=FileSaveName


Mike

"Lynn" wrote:

I need some help saving files during a macro:

1) I want to specify a path & file name for the active file to be saved
with - no user intervention required. The following code works for the file
name but location seems random - how do I specify where the file should be
saved?

ActiveWorkbook.SaveAs Filename:="my new file.xls"

2) I want to end my macro by having the user save the active workbook with
location and file name of their choice. I have used the following code to
display the SaveAs dialog but when the user clicks Save, the file is not
actually saved. What extra code is needed to execute the Save using location
& file name from the SaveAs dialog?

Application.FileDialog(msoFileDialogSaveAs).Show


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Saving the Active Workbook

Thanks SO much!!

"crazybass2" wrote:

Lynn

1) You need to specify the path. For example if you want the file to alway
save to the C drive in a folder called MyWorkbooks then your code should be
as follows:

ActiveWorkbook.SaveAs Filename:="C:\MyWorkbooks\my new file.xls"

2) That line of code only gets the filepath/name. It does not save the
file. Use the following:

FileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Microsoft Office Excel Workbook (*.xls), *.xls")
If FileSaveName = False Then End
ActiveWorkbook.SaveAs Filename:=FileSaveName


Mike

"Lynn" wrote:

I need some help saving files during a macro:

1) I want to specify a path & file name for the active file to be saved
with - no user intervention required. The following code works for the file
name but location seems random - how do I specify where the file should be
saved?

ActiveWorkbook.SaveAs Filename:="my new file.xls"

2) I want to end my macro by having the user save the active workbook with
location and file name of their choice. I have used the following code to
display the SaveAs dialog but when the user clicks Save, the file is not
actually saved. What extra code is needed to execute the Save using location
& file name from the SaveAs dialog?

Application.FileDialog(msoFileDialogSaveAs).Show


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
closing active windows without saving changes Tony Excel Programming 2 March 26th 05 10:24 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
Saving an external file without making it active JENNA Excel Programming 2 January 17th 04 11:51 PM
Saving only active sheet Peter[_18_] Excel Programming 1 July 22nd 03 11:31 AM


All times are GMT +1. The time now is 07:26 AM.

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"