Get Doc Id from name

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Get Doc Id from name

Post by moke@napconet.com »

I need to get the Id of an open document without knowing it's current index. I am using getdoc from name using this VB 6 code in ActiveX SDK ver. 2.0.41.2

Code: Select all

Dim DocID as long
Dim DocName as string
Dim Eat as long ' this is a throw away
'get id
CoPDFXCview1.GetDocumentFromName DocName, DocID, Eat
also tried

Call CoPDFXCview1.DoVerb(, "GetDocumentFromName", DocName, DocID, 0)


I continually get back "-1" for DocID which i assume means not found. I have tried DocName with full path, full filename, name w/o ext and still the same result. What am I doing wrong?

The main reason I need to know is to close the document but i can't seem to do that with name ony so if there is an easier way that would be helpful also, but i do need th Id for other stuff. Thanks
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Get Doc Id from name

Post by Corwin - Tracker Sup »

Actually method "GetDocumentFromName" is used when you need to get information about what document fired some event (in OnEvent notification).

You can always get ID of the current opened document by using "GetActiveDocument" function. Or you can call methods for document with zero index (this will be current opened document). For example

Code: Select all

Call CoPDFXCview1.DoVerb("Documents[0]", "Close", Nothing, Nothing)
will close active document.
The other way - you can remember document ID which you receive when call "OpenDocument" function.
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Re: Get Doc Id from name

Post by moke@napconet.com »

thanks fo rthe response. The issue i have is that in this situation there may be many documents opened and the document being closed may not be the current active document which is why i was trying a different method.

I had not thought about keeping track of the index of each document as it opens and insert them into and array. This will be a bit akward for my app because the users will be opening and closing many documents quickly but if there is no other way i guess i'll have to go that route. any other suggestions?
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Re: Get Doc Id from name

Post by moke@napconet.com »

ok... I tried keeping track as the documents are opened in inserting result into an array. it works better than i expected thanks for the suggestion!
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Get Doc Id from name

Post by John - Tracker Supp »

:)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com