Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Checking if you have a network connection
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 -------------------- -- clayton ------------------------------------------------------------------------ clayton's Profile: http://www.excelforum.com/member.php...fo&userid=4563 View this thread: http://www.excelforum.com/showthread...hreadid=547123 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Why does an Excel Recalc cause traffic over Network ? | Excel Discussion (Misc queries) | |||
Connection error to network drive | Excel Discussion (Misc queries) | |||
Connecting to a network drive using VBA | Excel Discussion (Misc queries) | |||
How do I save an OLAP connection to distribute with an Excel sheet | Excel Discussion (Misc queries) | |||
Why does Help go to network? How to avoid it? | Excel Discussion (Misc queries) |