Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Dynamically set SaveAs folder in VBA

I have a program in which the user is prompted to save a file at a certain
point.

What I would like to do is, when the code reaches the file save prompt
(which I can already do), have VBA quietly set MS-Excel to point to the
desired folder, so that if the user clicks [File] then [Save] the SaveAs
dialog box is pointed at the target folder, that's all.

Please note, that this should only occur if the code reaches this point and
I don't want this folder to be set as the default folder or anything like
that...

Thanks in advance for your assistance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Dynamically set SaveAs folder in VBA

Use GetSaveAsFilename

This is the start filder
MyPath = "C:\Users\Ron\test\"

Below is a basic example

Sub test()
Dim FName As Variant
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:\Users\Ron\test\"
ChDrive MyPath
ChDir MyPath

FName = Application.GetSaveAsFilename("yourfilename", filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
ActiveWorkbook.SaveCopyAs FName
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub





--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"XP" wrote in message ...
I have a program in which the user is prompted to save a file at a certain
point.

What I would like to do is, when the code reaches the file save prompt
(which I can already do), have VBA quietly set MS-Excel to point to the
desired folder, so that if the user clicks [File] then [Save] the SaveAs
dialog box is pointed at the target folder, that's all.

Please note, that this should only occur if the code reaches this point and
I don't want this folder to be set as the default folder or anything like
that...

Thanks in advance for your assistance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Dynamically set SaveAs folder in VBA


Thanks Ron; I forgot about that!



"Ron de Bruin" wrote:

Use GetSaveAsFilename

This is the start filder
MyPath = "C:\Users\Ron\test\"

Below is a basic example

Sub test()
Dim FName As Variant
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:\Users\Ron\test\"
ChDrive MyPath
ChDir MyPath

FName = Application.GetSaveAsFilename("yourfilename", filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
ActiveWorkbook.SaveCopyAs FName
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub





--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"XP" wrote in message ...
I have a program in which the user is prompted to save a file at a certain
point.

What I would like to do is, when the code reaches the file save prompt
(which I can already do), have VBA quietly set MS-Excel to point to the
desired folder, so that if the user clicks [File] then [Save] the SaveAs
dialog box is pointed at the target folder, that's all.

Please note, that this should only occur if the code reaches this point and
I don't want this folder to be set as the default folder or anything like
that...

Thanks in advance for your assistance.


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
Creating a folder on SaveAs leerem Excel Discussion (Misc queries) 6 December 8th 08 12:51 PM
SaveAS to a specific folder, with operator input of file name [email protected] Excel Discussion (Misc queries) 1 January 5th 06 03:19 PM
SaveAs Maceo - Specify Folder it Autoselects to Save In Z Nicodemous[_2_] Excel Programming 1 September 7th 05 12:22 PM
Can't 'SaveAs' Directly to Network Folder jbl25[_6_] Excel Programming 3 July 7th 05 02:36 PM
check and create folder for saveas Sunil Excel Programming 4 October 26th 04 01:11 PM


All times are GMT +1. The time now is 04:22 PM.

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

About Us

"It's about Microsoft Excel"