View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Peter Rooney Peter Rooney is offline
external usenet poster
 
Posts: 325
Default Problem saving to network drive

Tim,

Thanks for the tidyup advice.

The save still doesn't work though - the only way it will work is if I
replace the contents of the FolderName cell with something that begins with a
drive letter, OR if I first successfully save the file to a local drive (by
changing the contents of FolderName to D:\ for example), then chang
Foldername back to \\servername\ etc.

This is why I didn't post the code originally - once the workbook has saved
successfully, the code to save it to the network drive works OK.

Can you advise me as to how I should use debug.print as I haven't used it
before?

The problem seems to be a bit reminiscent of opening a file from a floppy,
changing the floppy and trying to save the file to the new floppy - you need
an intermittent successful save first before you can do it (showing my age
now!)

"Tim Williams" wrote:

Peter,

Have you tried a debug.print on the generated filename? I bet that
would show something up....
You have some duplicated code which could be simplified a bit.

Sub SaveMe()
dim SaveString as string
Application.DisplayAlerts = False
YearWeekTeamName
SetFolderName

SaveString=Year.Value & "-" & Format(WeekNumber.Value, "00") & ""

If TeamName.Value = "All Teams" Then
SaveString = SaveString & "Consolidation.xls"
Else
SaveString = SaveString & TeamName.Value & ".xls"
End If

debug.print FolderName & SaveString

ActiveWorkbook.SaveAs Filename:=FolderName & SaveString, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
_
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub

Hope that helps. Also check your "YearWeekTeamName" routine below: an
extra line in there....
Also may be time to turn on Option Explicit.

Tim.



"Peter Rooney" wrote in
message ...
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


### You're setting TeamName twice - is this the same range ??? I'm
guessing that wasn't intended.





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