Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
clayton
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does an Excel Recalc cause traffic over Network ? toc57 Excel Discussion (Misc queries) 0 May 12th 06 03:16 AM
Connection error to network drive dmlw96 Excel Discussion (Misc queries) 0 September 30th 05 08:24 PM
Connecting to a network drive using VBA Sri Excel Discussion (Misc queries) 0 June 7th 05 01:45 PM
How do I save an OLAP connection to distribute with an Excel sheet JohnA Excel Discussion (Misc queries) 0 May 19th 05 03:35 PM
Why does Help go to network? How to avoid it? [email protected] Excel Discussion (Misc queries) 5 March 11th 05 02:17 PM


All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"