PDA

View Full Version : Sleeper: How to save as with fixed name and server location ?



DT909
12-11-2017, 06:53 AM
Hello,

I'm currently blocked on this issue :

sFileSaveName = Application.GetSaveAsFilename(InitialFileName:=***, fileFilter:="Excel Files (*.xlsx), *.xlsx")

This opens a Save as dialog box, which is fine,
The file name is automatically generated ("***") which is also what I want,

But the default folder is C:/My Documents

This is not what I want. I want a default folder based on a server where the user can chose the folder where he wants to save the file.

Thanks for your help.

p45cal
12-11-2017, 07:04 AM
Include the path in the
InitialFileName:=

DT909
12-11-2017, 07:15 AM
I tried something like :


sFileSaveName = Application.GetSaveAsFilename(InitialFileName:="https://server/folder/" & ***, fileFilter:="Excel Files (*.xlsx), *.xlsx")

The dialog box opened the right path but in that case didn't put any name

I know that I'm doing a mistake somewhere. So I'm looking for the right code :)

Thanks

p45cal
12-11-2017, 08:19 AM
This works for me:

sFileSaveName = Application.GetSaveAsFilename(InitialFileName:="C:\blahblah\500 worst Songs\qwerty", fileFilter:="Excel Files (*.xlsx), *.xlsx")
as did this:

sFileSaveName = Application.GetSaveAsFilename(InitialFileName:="C:\blahblah\500 worst Songs\qwerty.xlsx", fileFilter:="Excel Files (*.xlsx), *.xlsx")

DT909
12-11-2017, 08:33 AM
It doesn't work for me.
2 things are important to precise :

In your code the path is a hard drive, in mine it's a web server
In your code the filename is fixed, in mine it's a variable (a unique ID generated from different values)

p45cal
12-11-2017, 09:00 AM
regarding variables, these all worked:
dddd = "qwerty"

sFileSaveName = Application.GetSaveAsFilename(InitialFileName:="C:\blahblah\500 worst Songs\" & dddd, fileFilter:="Excel Files (*.xlsx), *.xlsx")

dddd = "qwerty.xlsx"

sFileSaveName = Application.GetSaveAsFilename(InitialFileName:="C:\blahblah\500 worst Songs\" & dddd, fileFilter:="Excel Files (*.xlsx), *.xlsx")

dddd = "C:\blahblah\500 worst Songs\qwerty.xlsx"

sFileSaveName = Application.GetSaveAsFilename(InitialFileName:=dddd, fileFilter:="Excel Files (*.xlsx), *.xlsx")

regarding webservers, this is difficult to test; do you know if there's a specific web server available to the public that I can test this on?

DT909
12-11-2017, 09:07 AM
Yes you can test with Google Drive or Dropbox...

p45cal
12-11-2017, 10:03 AM
I'm struggling at the moment; there seem to be a few ways of doing this - Google drive can be mapped to look as if it's local, I guess that's not happening at your end. Can you give me an idea of what's in the this box when you do navigate to the right place:
21153

DT909
12-12-2017, 04:03 AM
Hi
There are just folders containing different files.
And for information it's a "Microsoft Sharepoint" server.

p45cal
12-12-2017, 12:18 PM
There seem to be some solutions on the web:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-msoffice_custom-mso_2007/vba-save-workbook-to-sharepoint/5eca44d1-a94e-4b28-ba20-fa3ae661af80?auth=1
https://stackoverflow.com/questions/32786792/vba-macro-to-save-to-sharepoint-with-dynamic-file-name
https://sharepoint.stackexchange.com/questions/133197/excel-vba-code-to-upload-document-into-sharepoint-online-2013
https://www.experts-exchange.com/questions/28624655/Excel-VBA-code-to-upload-a-file-to-SharePoint-Online.html
https://officeaccelerators.wordpress.com/2013/11/09/vba-code-to-uploaddownload-files-tofrom-sharepoint-library/