Skip to main content
Known Participant
April 29, 2008
Question

Indesign CS3: How to get the current document name?

  • April 29, 2008
  • 17 replies
  • 1781 views
Hallo!

How do I get the name of the current document loaded in Indesign?

Thanks,
Alois Blaimer
This topic has been closed for replies.

17 replies

Known Participant
June 26, 2008
...Plese Ignore the last post...<br /><br />docRef is the UIDRef of the document. Plese consider the following code<br /><br />IDocument *docFrom = Utils<ILayoutUIUtils>()->GetFrontDocument(); <br />if (docFrom == NULL ) <br /> break; <br />UIDRef docRef = GetUIDRef(docFrom )); <br /><br />InterfacePtr<IDocument> iDocument (docRef, IID_IDOCUMENT); <br />if(iDocument == nil) <br /> break; <br /><br />PMString docName; <br />iDocument->GetName(docName);
Known Participant
June 26, 2008
docRef is the UIDRef of the document.<br /><br />IDocument *docFrom = Utils<ILayoutUIUtils>()->GetFrontDocument();<br />if (docFrom == NULL )<br />break;<br /> pDoc = GetDocFromUIDRef(GetUIDRef(docFrom ));
Known Participant
June 26, 2008
what the parameter docRef refers?

thanks
subha
Known Participant
April 30, 2008
Here is the short and simple way<br />InterfacePtr<IDocument> iDocument (docRef, IID_IDOCUMENT);<br />if(iDocument == nil)<br /> break;<br /><br />PMString docName;<br />iDocument->GetName(docName);
Inspiring
April 29, 2008
IDocument is ok for most purposes. If you need the file, have a look at IDataBase. There won't be a file though when the document is not yet saved.

Dirk
Inspiring
April 29, 2008
That takes me to the header file IDocument.h from the CS3 SDK, which contains the following comments:

"Do not use the document's name to make assumptions about the name of the actual pub file in the file system."

I guess this "name" is not always the same as the opened document file name?

Which one are you looking for Alois?
Known Participant
April 29, 2008
I haven't tried this myself, but it looks like you should be able to use ILayoutUIUtils::GetFrontDocument to get a pointer to the active IDocument, then call IDocument::GetName to get the name.