Doubt regarding GetObjectByName Method

The PDF Creator enables you to create secure PDF documents and to view, print and process existing PDF documents.
If you have any questions about the installation and usage of the PDF Creator please post them here.
Post Reply
shaun
Posts: 16
Joined: Mon Jul 17 2006
Contact:

Doubt regarding GetObjectByName Method

Post by shaun »

Hi,

In the application which i'm developing I want to find out if a particular Text object exists in a PDF document and if the Text object is there then change the color of the text and if the Text object is not found then create the Text object.

i'm using the following code.

Dim PDF1 As New ACPDFCREACTIVEX.PDFCreactiveX
Dim objDummy as object

With PDF1
.SetLicenseKey LICENSEE, LICENSECODE
.Open App.Path & "\Testfileafterinsertingpages.pdf", ""

Set objDummy = .GetObjectByName("Text3")
....................

The GetObjectByName method works perfectly when the object "Text3" is there in the .pdf file. But if the object is not there then its throwing a runtime error. In my appplication its is necessary that i search for the object before i make a change.

Please tell me where i'm going wrong?.

Is there a better way to find an object?.

Thanks and Regards
Shaun
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

As you set GetObjectbyName works properly if the object exists, if it doesn't how could it find it? it is normal than not to find the object.

If text3 doesn't exist in the PDF document than it can't be retreived, what you can do in this case is search for a specific text that you know existing in the document and not for the text object.
shaun
Posts: 16
Joined: Mon Jul 17 2006
Contact:

Post by shaun »

Hi Joan,

I understand what you are saying. But what i want to do is in the opened PDF file, i have to check if an object exists or not. As you said if its there it can be retrieved. But my question is how to check if the object is there or not. I dont think i can check for the text(the contents). Because the contents of the Text Object is coming through a user entry.

Hope you are clear with this.

Shaun
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,


The .GetObjectByName() function will generate an exception if it does not encounter the object. You will just need to handle this exception.

On Error Resume Next
Set obj = .GetObjectByName("acText3")

Hope this helps
Post Reply