Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 801
  • Last Modified:

Trouble with AddFromGuid

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
RBianca
Asked:
RBianca
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
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
 
RBiancaAuthor Commented:
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
 
Rey Obrero (Capricorn1)Commented:
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
 
RBiancaAuthor Commented:
Thank you!  It did the trick!  Now if you could just explain why...?
0
 
Rey Obrero (Capricorn1)Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now