Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trouble with AddFromGuid

Posted on 2010-11-08
5
Medium Priority
?
791 Views
Last Modified: 2012-05-10
Good morning Geniuses!

I'm having a problem with a PDFCreator reference in Access 2003.  

When this application was originally rolled out to the users, PDFCreator was one of the references that was checked (included).  But when the users tried to run the app for the first time, they would wind up with a broken reference.  The only way to correct it was to uncheck the reference on the user's pc, then recheck it and all would be fine.

We tried to correct this by trying to trap for (and correct) broken references.  This was not successful.  We still had to make house calls to uncheck and recheck the reference.

This time around, I unchecked the reference before rolling the app out.  The code I added is supposed to check for the reference and if not found (not checked), it was supposed to add it from the GUID (see code below).  But it also doesn't work.  The reference remains unchecked even though it is not found.  

Since I grabbed the GUID from my own PC during testing, do you think it is not working because the GUID on my user's pc is different?  Or its location is different?  Or version?

I guess I really don't understand how the GUID works...

Thanks in advance for the help!

 
Dim ref As Reference
Dim PDFfound As Boolean

PDFfound = False

For Each ref In References
   If ref.name = "PDFCreator" Then
      PDFfound = True
   End If
Next ref

If Not PDFfound Then
   ReferenceFromGUID ("PDFCreator")
End If

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Function ReferenceFromGUID(strFilename As String) As Boolean 

If strFilename = "PDFCreator" Then
   References.AddFromGuid "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613}", 0, 0
   ReferenceFromGUID = True
End If

Exit_ReferenceFromGUID:
   Exit Function

Error_ReferenceFromGUID:
   MsgBox Err & ": " & Err.description
   ReferenceFromGUID = False
   Resume Exit_ReferenceFromGUID
   
End Function

Open in new window

0
Comment
Question by:RBianca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34085150
try this revision




Function ReferenceFromGUID(strFilename As String) As Boolean 
on error resume next
If strFilename = "PDFCreator" Then
do
   References.AddFromGuid "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613}", 0, 0
   ReferenceFromGUID = True
   if err=0 then 
        ReferenceFromGUID=true
        exit do
   end if
loop while false
End If


end function

Open in new window

0
 

Author Comment

by:RBianca
ID: 34085268
Hi, Capricorn1.
I will try this and let you know how it goes.  Just so I understand, are you thinking that it is a timing issue?
rb.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 34085339
btw, i forgot to comment this line

'  ReferenceFromGUID = True

Function ReferenceFromGUID(strFilename As String) As Boolean 
on error resume next
If strFilename = "PDFCreator" Then
do
   References.AddFromGuid "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613}", 0, 0
   '  ReferenceFromGUID = True
   if err=0 then 
        ReferenceFromGUID=true
        exit do
   end if
loop while false
End If


end function

Open in new window

0
 

Author Closing Comment

by:RBianca
ID: 34087674
Thank you!  It did the trick!  Now if you could just explain why...?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34087782
you were right at the timing issue, so you need to make the codes persistent until you get an error=0 which means that there is no error.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question