Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Update links only if file exists

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Update links only if file exists

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


"Greg H." wrote in message
...
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?


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
Saving a file that you do not want to update the links to other fi Derric New Users to Excel 1 July 10th 08 04:56 AM
Update links in closed file Henk Frigge[_2_] Excel Programming 1 February 14th 06 12:36 AM
update a closed file via links Rob Robbins Excel Discussion (Misc queries) 2 July 13th 05 09:25 PM
Automatic update of links in destination file when source file mo. Brucgil Excel Discussion (Misc queries) 0 December 2nd 04 04:07 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 02:01 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"