GetSaveAsFilename() ALWAYS opens in My Documents even with ChDirNet()

S3RG388

New Member
Joined
Jun 11, 2017
Messages
12
Hi Everyone,

I have a problem with getting GetSaveAsFileName() function to open Save dialogue box in a Network drive instead of always opening in my documents.
Basically, I have implemented a workaround to change path to a network drive via:

Top of my working module:

Private Declare Function SetCurrentDirectoryA Lib _
"kernel32" (ByVal lpPathName As String) As Long

Sub ChDirNet(szPath As String)
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(szPath)
If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
End Sub

In my SaveAs() module the following code:

ChDirNet "\\test\input"
xFileName = Application.GetSaveAsFilename("\\test\input\filename.xls")

However, I STILL can not get the save as dialogue box to open in the \\test\input network path.

Can someone please advice?

Any help would be appreciated!

Thank you kindly.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hia
You have to change the drive first ie
Code:
 ChDrive "E:"
 ChDir "E:\ProgramFiles"
 fname = Application.GetSaveAsFilename
But it has to be a drive letter, rather than the UNC that you're using.
HTH
 
Upvote 0
Thank you but I am not going to map drives on my user's PCs hence can't use ChDr... I need a solution where I can simply refer to a network path accessible to the user.
 
Upvote 0
If the file is being saved to the same drive, but a different folder you could use
Code:
 ChDrive Left(ActiveWorkbook.Path, 2)
But if the file needs to be saved to a different drive, I'm not sure it's possible to do.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top