Skip to main content
Inspiring
February 10, 2024
Answered

Text Variable(File Name) not getting original file name when opening document as copy

  • February 10, 2024
  • 4 replies
  • 924 views

Hello All,

I have a InDesign file which has text variable (File Name) inserted in text frame. I open indesign file as a copy of original file like below.

 

ErrorCode cmdErrCode = Utils<IDocumentCommands>()->Open(&tempCopyInDesignFileRef, inDesignIDFile, K2::kSuppressUI, IOpenFileCmdData::kOpenCopy, IOpenFileCmdData::kNotUseLockFile, kFalse);

 

Issue is when I try to get text from text frame where text variable(File Name) is set. It gives me text like “Untitled-XX” instead of original file name. 

 

Is there way I can get original file name? Please suggest.

 

Thank You

Chetan S

This topic has been closed for replies.
Correct answer Alo Lohrii

Because you opened a copy of the document(IOpenFileCmdData::kOpenCopy) and not the original(IOpenFileCmdData::kOpenOriginal), opened document is only in memory and not saved yet, hence its returning  default document name(Untitled-x) instead of the original document name, which is the expected behaviour. If you need to retrieve the original document name, change the open flags to IOpenFileCmdData::kOpenOriginal

4 replies

Alo Lohrii
Community Manager
Alo LohriiCommunity ManagerCorrect answer
Community Manager
March 7, 2024

Because you opened a copy of the document(IOpenFileCmdData::kOpenCopy) and not the original(IOpenFileCmdData::kOpenOriginal), opened document is only in memory and not saved yet, hence its returning  default document name(Untitled-x) instead of the original document name, which is the expected behaviour. If you need to retrieve the original document name, change the open flags to IOpenFileCmdData::kOpenOriginal

Robert at ID-Tasker
Brainiac
February 10, 2024

@Chetan S

 

Correct me if I'm wrong - you are good with C/C++ and someone asked you to write a plugin - but you don't use InDesign daily?

 

Chetan SAuthor
Inspiring
February 12, 2024

yes I have written plugin in in C/C++,  I am duplicating(creating copy) InDesign file and cant use original file as I am modifying it. 

Robert at ID-Tasker
Brainiac
February 10, 2024

I know even less about plugins than about JS - but isn't: 

&tempCopyInDesignFileRef

a reference to your original file?

 

Can't you get the name from it?

 

Chetan SAuthor
Inspiring
February 10, 2024

2nd parameter is original IDFile

 

I am opening InDesing document and parsing its object to process. there is text frame which contains Text variable "File Name", so for that text frame I should get name of original file but I am getting “Untitled-1”.

Chetan SAuthor
Inspiring
February 10, 2024

No, you are working on a completely NEW document - that is just a copy of the original file - all variables that are defined in the document - are pointing to the document they are in - not some old document. 

 

It's like you would expect that after creating new, blank document and doing drag&drop from another document - that values of the VARIABLES will still point to the other document.

 

Those are text VARIABLES - not constants, they change and show current information. 

 

If you add variable that shows current page - and you move it to a different page - which page number would you expect to see? 

 


Yes correct, is there way I can identify where Text variable ("File Name") is applied?

Robert at ID-Tasker
Brainiac
February 10, 2024

Text variable "File Name" is linked - and automatically updated - to the CURRENT document - how can you expect it to be linked with the old file?