Problem saving to network drive
Tim,
Here it is:
Sub SaveMe()
Application.DisplayAlerts = False
YearWeekTeamName
SetFolderName
If TeamName.Value = "All Teams" Then
SetFolderName
SaveString = Year.Value & "-" & Format(WeekNumber.Value, "00") & " "
& "Consolidation.xls"
ActiveWorkbook.SaveAs Filename:=FolderName & SaveString, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Else
SaveString = Year.Value & "-" & Format(WeekNumber.Value, "00") & " "
& TeamName.Value & ".xls"
ActiveWorkbook.SaveAs Filename:=FolderName & SaveString, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End If
End Sub
Sub YearWeekTeamName() 'defines cells containing entries to make up filename
Set WeekNumber = Sheets("Database").Range("WeekNumber")
Set Year = Sheets("Database").Range("Year")
Set TeamName = Sheets("Database").Range("TeamName")
Set TeamName = DBSheet.Range("TeamName")
end sub
Sub SetFolderName() 'cell containing the offending \\ prefixed foldername
FolderName = Sheets("Database").Range("FolderName").Value
End Sub
Hope this helps. At the moment, we're having to make sure that the cell
"FolderName" contains something prefixed with a drive letter, which is a bit
awkward, as not everyone maps o the folder in the same way.
Cheers
Pete
"Tim Williams" wrote:
Why not post the code? There *may* be something "wrong" with it if it
does not work....
UNC paths have always worked fine for me in XL.
Tim
"Peter Rooney" wrote in
message ...
Good morning, all,
I posted a similar question a few days ago, but I think it might
have got
lost, so I'll try again.
I have a number of workbooks that contain a macro to save to a
network drive
and a macro to save to a local drive.
If I open a workbook and run its networksave macro, I get a runtime
message
1004 "Cannot access file xxx.xls"
If however I open the workbook, first run its localsave macro (which
runs
OK) and THEN run the networksave macro, then everything is OK.
I can then run the networksave macro as often as I want, but if I
close the
file and open it again, the problem reoccurs.
I'm not going to post the code as, since it runs OK after I've done
a local
save, I don't think there can be anything "wrong" with it. As the
problem
occurs over a number of different workbooks, I don't think that it's
a
workbook corruption issue, either. And nobody else has the workbooks
open.
Can ANYONE help, please?
Yours in desperation
Pete
Can anyone sugge
|