In case you're not familiar with Text Variables, here are a couple of links to good resources to learn more about them.
Adobe Help File : Text Variables
InDesign Secrets: Using variables in InDesign slugs
Recently, I found a couple of different instances where text variables do not output as expected. I used the different workarounds for both instances, and I wanted to share it here for the inevitable time when some other poor InDesign user encounters the same problem.
Text Variable Error Type 1: File Name Extension
On my master page, I have placed a File Name text variable. Notice how "Include File Extension" is unchecked. It all looks good so far. See how the extension is not displayed? (If it was diplayed, there would be a .indd at the end.
But see what happens when I then place the first InDesign document into a second InDesign document. The extension appears! I tried releasing the object from the master page of the first InDesign document, but that didn't change anything. The extension still displays in the second InDesign document. (On a side note, because my text frame was fit the the exact size of the original text, it now looks very crowded trying to also fit an extension into the same size text frame.)
In this case, the workaround was to simply NOT USE the File Name variable. Instead, I had to manually type the file name in each and every single chapter, and I also have to remember to change this text whenever I do a Save As and for a new chapter.
Text Variable Error Type 2: Page Numbers Gone Wild
My second unexplainable text variable problem had to do with Page Numbers. You see, page numbers aren't listed in the Text Variable dialog box, but I think they should be. By the very nature of what they do, Page Numbers are variables.
Page numbers are so commonplace. Who doesn't use page numbers? Perhaps that's why they are accessed in a different spot in InDesign, outside of the Text Variable dialog box.
But Text Variables (the ones listed below) seem a little more mysterious, and are harder to find, so fewer people use them. Granted, Text Variables have more options, like including text before and text after, and plenty of different ways to customize a Modification Date.
But page numbers have a lot in common with Text Variables. One type of page number even made it into the Text Variables dialog box: "Last Page Number." But we won't tell his other page number buddies about that. They'd just get jealous.
The type of page number I experienced problems with was "Current Page Number,"which is located under: Type > Insert Special Character > Markers (see screenshot above).
On a recent project, I had one document where the page numbers went completely crazy...but only in the PDF. All was fine in the InDesign document. But when I exported the document to PDF, the page numbers did not display properly in the footer. They looked something like this: (click to enlarge)
Now, keep in mind that I didn't put in any section markers. I have no idea what caused the problem. I exported the file as an INX and then reopened the file and put it back into the correct spot in the book, but the problem persisted. I tried Acrobat 4.0 compatibility, as well as opening the file in Acrobat 9 and X. I even tried to go into the PDF and edit the page numbers there, but when I edited several of the page numbers, all the page numbers I edited (with the Text Edit tool in Acrobat) reverted back to whatever was the latest page number that I typed. So in this example, I edited the Left-hand facing pages, ending with the last left-hand facing page, changing that to 94. Then ALL the previous page numbers that I just edited also became page 94. WHAT??? I am stumped.
I also tried exporting just a single chapter from the book, and replacing the incorrect pages in Acrobat, but again...it didn't work. In that case, instead of displaying the correct page number, the first Left-facing page displayed the word "Variable." Aha! I knew page numbers were Variables!
However, in this case of Page Numbers Gone Wild, I found that simply detaching the page number text frames from the master page fixed the problem. Then they all outputted as expected.
Edit: 3-11-15: Today I once again encountered the problem where the word "Variable" instead of the page number appears in random places in the PDF. The solution to the problem was to open every file in the book and then export the PDF with all the files open.
Edit 1-8-16: I again encountered the strange "Variable" issue and found that instead of detaching the items from the master page, I could simply reapply the master page and the page number then displayed properly.
If this was helpful, please also check out a related post: Why Does InDesign Think There are 69 days in the Month?