OK...I have been a long time lurker, have done a forum search and can't seem to find the solution to my VBA issue.
Crux of what I am trying to accomplish - I have a workbook template I am distributing via SharePoint, once opened by the user I am firing the save code from a button. When this code fires, it creates a folder and saves the document to a "user" document library - this code works fine. The issue I am running into is doing the follow-up check when the user saves subsequently so if the customer name is updated or a customer number is changed (many times a customer number is not available on the initial save) it renames the folder and workbook to this new information.
So here is the issue I am running into: The code I have changes the directory folder and workbook name without issue but does not change the name of the document that is open (which is the document that is changing in the folder itself). This causes the "save" function to fail as the document no longer exists in SharePoint (as it's been renamed as I want it to be).
I know that's a lot of writing but hope it helps in understanding the issue. Here is the code that does the name change on the folder and file - if more code is needed to understand, please let me know. I am working in Excel 2003, and SharePoint 2003.
If Dir("\\las\LAS Document Library\" & CurrentDir, vbDirectory) = "" Then
MkDir ("\\las\LAS Document Library\" & FileNameSave)
ActiveWorkbook.SaveAs Filename:="http://las/LAS Document Library/" & FileNameSave & "/" & FileNameSave & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ElseIf UpdateFlag = 1 Then
'Change Name of file
Name "\\las\LAS Document Library\" & FileNameSave2 & "\" & FileNameSave2 & ".xls" As "\\las\LAS Document Library\" & FileNameSave2 & "\" & FileNameSave & ".xls"
'Change Name of directory
Name "\\las\LAS Document Library\" & FileNameSave2 As "\\las\LAS Document Library\" & FileNameSave
Else
ActiveWorkbook.Save
End If
Any help or suggestions would be greatly appreciated as I am stuck on how to fix.
Thank you!
Crux of what I am trying to accomplish - I have a workbook template I am distributing via SharePoint, once opened by the user I am firing the save code from a button. When this code fires, it creates a folder and saves the document to a "user" document library - this code works fine. The issue I am running into is doing the follow-up check when the user saves subsequently so if the customer name is updated or a customer number is changed (many times a customer number is not available on the initial save) it renames the folder and workbook to this new information.
So here is the issue I am running into: The code I have changes the directory folder and workbook name without issue but does not change the name of the document that is open (which is the document that is changing in the folder itself). This causes the "save" function to fail as the document no longer exists in SharePoint (as it's been renamed as I want it to be).
I know that's a lot of writing but hope it helps in understanding the issue. Here is the code that does the name change on the folder and file - if more code is needed to understand, please let me know. I am working in Excel 2003, and SharePoint 2003.
If Dir("\\las\LAS Document Library\" & CurrentDir, vbDirectory) = "" Then
MkDir ("\\las\LAS Document Library\" & FileNameSave)
ActiveWorkbook.SaveAs Filename:="http://las/LAS Document Library/" & FileNameSave & "/" & FileNameSave & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ElseIf UpdateFlag = 1 Then
'Change Name of file
Name "\\las\LAS Document Library\" & FileNameSave2 & "\" & FileNameSave2 & ".xls" As "\\las\LAS Document Library\" & FileNameSave2 & "\" & FileNameSave & ".xls"
'Change Name of directory
Name "\\las\LAS Document Library\" & FileNameSave2 As "\\las\LAS Document Library\" & FileNameSave
Else
ActiveWorkbook.Save
End If
Any help or suggestions would be greatly appreciated as I am stuck on how to fix.
Thank you!