PDA

View Full Version : Sleeper: Writing File Address to Save File Directly to a Shared Folder



gdougher
02-15-2024, 11:33 AM
My users are sparse in their understanding of computers. I gave them a Form in Excel to use and included a "Save As" button. I want the VBA attached to the button to have the File Explorer open to a shared folder on SharePoint that all users have access to. I thought that would be easy, but the File Explorer only opens to their respective Documents folder which means the user then needs to browse to the needed folder to save the Form, which is problematic for some users. Any assistance, if this is possible, would be greatly appreciated.
Thank you.

Paul_Hossler
02-15-2024, 01:11 PM
Don't have Sharepoint anymore, but try something like this

I use the commented out part for local drives


Option Explicit

Sub Concept()
Dim sFilename As String

'i don;t have sharepoint anymore, but record a macro where you save it to get the server address, something like

'"\\sp001-server@SSL\sites\SiteCollectionName\DocumentLibrary\ Filename.xlsm"

sFilename = Application.GetSaveAsFilename(Title:="Where to save the file")

If sFilename = "False" Then
MsgBox "Not going to save it"
Exit Sub
End If

sFilename = "\\sp001-server@SSL\sites\SiteCollectionName\DocumentLibrary\" & sFilename & ".xlsm"

MsgBox sFilename


'can't really save it
ThisWorkbook.SaveAs sFilename, xlOpenXMLWorkbookMacroEnabled



'----------------------------------------------- similar for local drive
' ChDrive "D:"
' ChDir "\test"
'
'
' sFilename = Application.GetSaveAsFilename(Title:="Where to save the file")
'
' If sFilename = "False" Then
' MsgBox "Not going to save it"
' Exit Sub
' End If
'
'
' sFilename = sFilename & ".xlsm"
'
' MsgBox sFilename
'
' ThisWorkbook.SaveAs sFilename, xlOpenXMLWorkbookMacroEnabled




End Sub