PC Review


Reply
Thread Tools Rate Thread

Check for missing references on opening

 
 
Cresta
Guest
Posts: n/a
 
      1st Apr 2008
Hello

I would like have an Excel file check for missing references as the file is
opening and remove or warn of the missing reference, not stop the show.
At the moment if any references are missing all of the remaining references
don't appear to be installed either, causing code reference errors as the
file continues to open.

Any ideas
Thanks
 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      1st Apr 2008
Hi
Have you tried searching this group using,

Check for missing references on opening

regards
Paul

On Apr 1, 10:52*am, Cresta <Cre...@discussions.microsoft.com> wrote:
> Hello
>
> I would like have an Excel file check for missing references as the file is
> opening and remove or warn of the missing reference, not stop the show.
> At the moment if any references are missing all of the remaining references
> don't appear to be installed either, causing code reference errors as the
> file continues to open.
>
> Any ideas
> Thanks


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      1st Apr 2008
There may be a reason for a missing reference, removing it might not solve
your problems. Sometimes if it's an anticipated versioning issue you can
remove the missing ref then re-add it. Following is a direct answer to your
question but be aware it might cause more problems than it solves.

Private Sub Workbook_Open()
Dim bAskFirst As Boolean
Dim bDel As Boolean
Dim oRefs As Object ' References
Dim oRef As Object ' Reference
Dim sDes As String

bAskFirst = True ' ask before deleting

Set oRefs = Me.VBProject.References
On Error Resume Next
For Each oRef In oRefs

sDes = oRef.Description
If Err Then
If bAskFirst Then
bDel = MsgBox( _
"Remove missing ref ?" & VBA.Constants.vbCr & _
oRef.Name, 4) = 6 ' vbYesNo = 4, vbYes = 6
Else
bDel = True
End If

If bDel Then
oRefs.Remove oRef
Debug.Print oRef.Name, "Removed"
End If
Err.Clear
End If
Next

End Sub

In XL2002 and later you'll need to check Trust access to VB projects.

If you anticipate a missing reference fully qualify all VBA libraries like
VBA.Constants in the above. Although unqualified 'Constants' doesn't
generally cause problems unqualified String and DateTime functions probably
will.

Regards,
Peter T

PS
Sandusky - Search this and most ng's in Google groups


"Cresta" <(E-Mail Removed)> wrote in message
news:5832323C-BC1E-4FF8-A72C-(E-Mail Removed)...
> Hello
>
> I would like have an Excel file check for missing references as the file

is
> opening and remove or warn of the missing reference, not stop the show.
> At the moment if any references are missing all of the remaining

references
> don't appear to be installed either, causing code reference errors as the
> file continues to open.
>
> Any ideas
> Thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find object references.. How do I find references to missing objec rocknroj Microsoft Frontpage 7 2nd Feb 2008 09:29 AM
Check for missing references e.mel Microsoft Access Form Coding 7 7th Aug 2006 02:01 PM
Tools...References shows "MISSING:" in front of 2 references =?Utf-8?B?TWlrZSBKYW1lc3Nvbg==?= Microsoft Excel Programming 1 19th Oct 2005 06:33 PM
References.Remove References(1) DOES NOT WORK for "MISSING:" Refs Jamie Carper Microsoft Excel Programming 0 27th May 2004 04:22 PM
Re: Missing references when opening database in XP and 2000 Rutger Laarveld Microsoft Access VBA Modules 0 10th Jul 2003 02:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 AM.