Insert FIELD works on one drawing, but not the other

Started by RudySchneider, August 23, 2017, 08:31:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RudySchneider

I created a Visio drawing to experiment with an automated numbering and naming scheme for drawing title blocks.  In it, I placed two rectangles.

In one of the rectangles, I inserted a text FIELD with a custom formula to extract the "number" portion of the file name.

In the other rectangle, I inserted a text FIELD with a custom formula to extract the "name" portion of the file name.

So, if I saved the file as "1234567_Test File.vsdx", the first rectangle would show "1234567" and the second rectangle would show "Test File" (the formula ignores the file extension).

The problem I'm having is that, while the rectangles update properly in the (new) experimental file, and I can copy and paste the rectangles into a new Visio file, and they follow the file renaming convention, I do not get the expected results if I copy and paste the rectangles into a previously created file!  When I do so, the content of the rectangles stays the same as the file from which I copied them!  Moreover, if I try to edit the text FIELD, it tells me the formula is in error.

The FIELD formula to extract the number is
IF(IF(ISERR(LEFT(FILENAME(),1)*1),0,1)=1,IF(FIND("_",FILENAME())<10,LEFT(FILENAME(),FIND("_",FILENAME())-1),IF(FIND(" ",FILENAME())<10,LEFT(FILENAME(),FIND(" ",FILENAME())-1),"")),"")

While the formula to extract the name is
IF(IF(ISERR(LEFT(FILENAME(),1)*1),0,1)=1,MID(FILENAME(),IF(FIND("_",FILENAME())<10,FIND("_",FILENAME()),IF(FIND(" ",FILENAME())<10,FIND(" ",FILENAME()),0))+1,LEN(FILENAME())-IF(FIND("_",FILENAME())<10,FIND("_",FILENAME()),IF(FIND(" ",FILENAME())<10,FIND(" ",FILENAME()),0))-5),(LEFT(FILENAME(),LEN(FILENAME())-5)))

Yes, they are a bit unwieldy, but they allow for different file naming formats.

So why does this work in a "new" file, and not in an "old" one?  I've tried comparing the file options, and/or the shapesheets, but nothing pops out.  It must be something simple, right?
There are no problems, only opportunities

Surrogate

Quote from: RudySchneider on August 23, 2017, 08:31:11 PM
So why does this work in a "new" file, and not in an "old" one? 
what you mean as new/old file ?

RudySchneider

Surrogate ---
Like I said, I created a simple "experiment" Visio drawing, to experiment with how I might go about automating the title blocks for an "older" set of Visio drawings.  After I'd figured out how to get the FIELDs to work on the experimental drawing, I figured all I needed to do was insert that same FIELD into my "older" drawings.

But no go.  The only thing I can think of is that there is some setting in the "old" drawing files that is not allowing me to insert these long formulas.

If I put a simple text FIELD into the "old" drawings, like "=FILENAME()", it works fine, but I'd like to extract the NUMBER and NAME portions from FILENAME().
There are no problems, only opportunities

RudySchneider

Hmmm, there's something even more weird going on.  If I do a "Save As" and rename the file, the text content of the rectangles updates correctly.  But if I do a "Save As" and click on the name of one of my "old" files, the rectangles DO NOT update, and I get an ERROR when I insert the FIELD formula again.

WEIRD...
There are no problems, only opportunities

Surrogate

I create experimental drawing in Visio 2010. Change that drawing filename few times, it works

RudySchneider

AHA!  I originally experimented in Excel.  When I put one of my old file names into the NAME cell in Excel, it too shows an error.  So apparently I need to "adjust" the formula...
There are no problems, only opportunities

RudySchneider

Yup, I had an error in the formula using FIND.  It's all good now...
There are no problems, only opportunities