C
clayton
Hello,
I am using the below code (found on this site) to do a "Quick Save" to
a folder on my server. As it is now if there is not connection to the
network it saves the file locally to my "My Documents". Strange...
Anyway, I would like to know how to make this code tell me if there is
no connection and if not to ask what I would like to do with the file
(where to save it to).
Code:
--------------------
Public this_year
Sub Save_File()
this_year = Format(Date, "yyyy")
If Range("lotcode") = "" Then
MsgBox "Please enter a lot code"
Else
Call FindFile("totalpath")
End If
End Sub
Function FindFile(ByRef strPath As String)
Dim strFile As String
strFile = Dir(strPath)
If Len(strFile) Then
On Error Resume Next
fname = Range("product").Text & "-" & Range("lotcode").Text & ".xls"
pathname = "\\mynetwork folder\sub folder\" ' Substitute your pathname here
totalpath = pathname & this_year & "\"
ActiveWorkbook.SaveAs Filename:=totalpath & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Else
On Error Resume Next
fname = Range("product").Text & "-" & Range("lotcode").Text & ".xls"
pathname = "\\mynetwork folder\sub folder\" ' Substitute your pathname here
totalpath = pathname & this_year & "\"
MkDir totalpath
ActiveWorkbook.SaveAs Filename:=totalpath & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End If
End Function
I am using the below code (found on this site) to do a "Quick Save" to
a folder on my server. As it is now if there is not connection to the
network it saves the file locally to my "My Documents". Strange...
Anyway, I would like to know how to make this code tell me if there is
no connection and if not to ask what I would like to do with the file
(where to save it to).
Code:
--------------------
Public this_year
Sub Save_File()
this_year = Format(Date, "yyyy")
If Range("lotcode") = "" Then
MsgBox "Please enter a lot code"
Else
Call FindFile("totalpath")
End If
End Sub
Function FindFile(ByRef strPath As String)
Dim strFile As String
strFile = Dir(strPath)
If Len(strFile) Then
On Error Resume Next
fname = Range("product").Text & "-" & Range("lotcode").Text & ".xls"
pathname = "\\mynetwork folder\sub folder\" ' Substitute your pathname here
totalpath = pathname & this_year & "\"
ActiveWorkbook.SaveAs Filename:=totalpath & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Else
On Error Resume Next
fname = Range("product").Text & "-" & Range("lotcode").Text & ".xls"
pathname = "\\mynetwork folder\sub folder\" ' Substitute your pathname here
totalpath = pathname & this_year & "\"
MkDir totalpath
ActiveWorkbook.SaveAs Filename:=totalpath & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End If
End Function