Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Update links only if file exists

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg H. - 15 May 2008 16:35 GMT
I have built a Year to date report for my department that I send out on a
monthly basis.  The main file pulls data from other documents to compile
everything.  Because I know the name of every file it will pull from (its not
hard with you watched Sesame Street and learned your months) I set up all the
equations in the future months to already pull from those files.  Problem is
when I open the document and select update links, it errors out once I come
to a file it can not find.  Is there a way for it to skip over a file if it
does not exists and continue to look for the other files, updated those that
are there?
RB Smissaert - 15 May 2008 22:48 GMT
Use a simple function like this:

Function bFileExists(ByVal sFile As String) As Boolean

   Dim lAttr As Long

   On Error Resume Next
   lAttr = GetAttr(sFile)
   bFileExists = (Err.Number = 0) And ((lAttr And vbDirectory) = 0)
   On Error GoTo 0

End Function

Use it like this:

If bFileExists(yourfilepath) then
'do whatever code needs doing here
Else
'Skip the file
End If

RBS

>I have built a Year to date report for my department that I send out on a
> monthly basis.  The main file pulls data from other documents to compile
[quoted text clipped - 11 lines]
> that
> are there?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.