-
Solved: Excel 2003 - Is it complicated to save to a shared network drive?
My question is below this code:
[vba]Private Sub CommandButton2_Click()
Dim wb As Workbook
Dim fileSaveName As String
Dim InitFileName As String
Dim strDate As String
strDate = Format(Now, "dd-mmm-yy h-mm-ss")
InitFileName = "C:\Users\Owner\Desktop\" & Range("I4").Value & "_" & strDate
Sheets(Array("Packing Slip", "C of C", "Invoice", "P Slip")).Copy
Set wb = ActiveWorkbook
fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitFileName, _
filefilter:="Excel files , *.xls")
If fileSaveName <> "False" Then
wb.SaveAs fileSaveName
wb.Close
Else
wb.Close False
Exit Sub
End If
End Sub[/vba] The code I put together above works fine to save four sheets as a new workbook.
I'm wondering if it will work if used with a shared network path
Changing this:
[vba]InitFileName = "C:\Users\Owner\Desktop\" & Range("I4").Value & "_" & strDate[/vba] To this:
[vba]InitFileName = "\\CompanyShare\folder1\" & Range("I4").Value & "_" & strDate[/vba] I only go into the factory a couple times a month so I have no way to test it. - I am hoping I do not need to use a big long API routine to get the save to path into my routine.
Thanks in advance for some insight.
-
If the folder is correct and the user has read/write/delete access rights, then it should work just fine.
-
Thanks Jan,
The user will have read/write/delete access rights, that I am sure of.
If it doesn't work, I will be ok even if I skip navigating in code to folder1 and save directly to \\CompanyShare\ and I found this short API call that looks like it will get me there
[vba]Declare Function SetCurrentDirectoryA Lib "KERNEL32" (ByVal lpPathName As String) As Long
SetCurrentDirectoryA "\\CompanyShare\"
InitFileName = Range("I4").Value & "_" & strDate [/vba]
API found at: http://www.eggheadcafe.com/community...ork-drive.aspx
I will mark this as solved and post back in a couple weeks when I get a chance to test it.
Thanks again, I really appreciate you letting me tap into your brain and experience.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules