FILENAME() Shapesheet function does not update

Started by huever, October 15, 2019, 06:42:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

huever

Hello,

I am trying to use the name of an open Visio file in a property of one of my shapes on Visio Drawing in order to show it on the drawing.


I observed such behaviour: when I save and close the file and then I change the name of the file the actual Value of my Identifier property does not change unless I enter the Shapesheet and go to Value cell pressing <Enter> key. I would like to do it this way that when the name of the file changes some shapes' properties on my drawing also change accordingly without any updating (entering Shapesheet and typing the "FILENAME()" formula again).

Is that possible to do it? So "FILENAME()" automatically changes value when the file is being open with a new name.

I found out that when I save the file as .vsd not .vsdx it works as expected (after opening the file the cells update themselves). The problem occurs only when saving to .vsdx format..

Thanks for your support. I attached a testing file (when it is opened the Idendifier property value does not follow the real file name).

Surrogate

Why you ask about this issue in Programming and code chapter?
You can use vsd-documents, why you need save it in vsdx?

huever

I'm sorry if this is the wrong place to ask.
I need to save files in vsdx, because, for example they are large and it is easier to work with them when saved as .vsdx.

vojo

probably should try DEPENDSON to trigger filename() refresh

filename() + dependson(<some cell that changes regularly...color or locx...maybe time() works as well>)

Yacine

#4
@Surrogate, come on don't be so picky. We don't really care about the right category. Do we?  :D мир


@huever,

I checked your file and noticed that the shape was not prepared as it should have (inserted field) and the font colour was set to white.

Well so far. Correcting the shape, by inserting DIRECTLY the field as text - not via the according prop field - showed no problem so ever  (Visio 2016 on Windows 10).
(Select the shape, hit F2, go to menu point "insert" and choose "field", under file properties choose "filename".

Cheers, Y.
Yacine

Surrogate

I just intrested which way huever want use ! In one organization where i worked in 2005-2010 VBA was prohibited.
May be he have same limitation ?

Two weeks ago i suggest update field value in that thread.

wapperdude

Visio 2019 works fine too.  The problem with using shape property is that will not pickup the filename change.  It is looking for a user input.  You can use technique suggested by Yacine.  If you want an intermediate step for reference purposes, create a User Defined entry, value = FILENAME(), and then insert Field > User Defined entry.  Either way works fine, though, for displaying filename.
Visio 2019 Pro

huever

"The problem with using shape property is that will not pickup the filename change."

- That is exactly the issue.

Thanks for your answers, I will try to do it with inserting Text Field and User Defined entry  :)

Sorry again for posting in wrong section.

Croc

#8
QuoteCorrecting the shape, by inserting DIRECTLY the field as text
Visio 2013, Windows 7 - function does not work. (See animated gif)
---
GIF doesn't work? I also posted it in DropBox -  https://www.dropbox.com/s/3tmv0lik52fj75w/FileNameBag.gif?dl=0

Croc

#9
Visio 2019, Windows 10. Similarly, the function is lying after manually renaming the file. Save does not fix the situation. SaveAs corrects.
------------
Updated
I suggest replacing the line in the description of the function
"Returns a document's file name as a string."
per line
"SOMETIMES returns a document's file name as a string. The function stops working after manually renaming the file and restores after saving the file under a different name."
Trying to trick Visio with = SETF ("User.FileName", "FILENAME ()") is futile.
You may try to use the reference to TheDoc!User.Filename instead of FILENAME (), and rewrite the formula in TheDoc!User.Filename programmatically when you open the document.
Private Sub Document_DocumentOpened (ByVal doc As IVDocument)
    ActiveDocument.DocumentSheet.Cells ("User.FileName"). FormulaU = """FILENAME ()"""
    ActiveDocument.DocumentSheet.Cells ("User.FileName"). FormulaU = "FILENAME ()"
End sub

vojo


huever

I have Visio 2019, Windows 10. This is exactly as Croc says. The only solution I found is to programatically rewrite the formulas in the cells.
Do something like (pseudocode):

string s = cell.Formula
cell.Formula = ""
cell.Formula = s

Then it updates. But with vsd format it was quite intuitive - I could extract some part of the file name and after updating the name of the file (manually, in Windows Explorer) and opening the Visio Document again I could see the data refreshed everywhere. Now I have to run a macro to have this effect. I tried SETF, User Defined cell, Insert Text Field.. Ofc I can always run some macro to do it, but I can't save the file with the macro (I  need to remember to delete it) due to policy we have (file will be considered as potentially unsafe..).

:(

Croc

#12
You can try the option without a program.
In one cell we make the minute timer, but we distinguish only even and odd values.
With an even value, we write a function, with an odd value, its value.
Very cumbersome, but it works :)

Scratch.A1=IF(Scratch.C1=0,SETF("Fields.Value","FileName()"),SETF("Fields.Value",GetVal(Fields.Value)))+DEPENDSON(Scratch.B1)
Scratch.B1=NOW()
Scratch.C1=1
Scratch.D1==IF(GetVal(Scratch.C1)>0,SETF(GetRef(Scratch.C1),"0"),SETF(GetRef(Scratch.C1),"1"))+DEPENDSON(Scratch.B1)

wapperdude

After watching Croc's GIF, went back and was able to confirm that changing filename externally in FileExplorer will not be caught by the NAME() fcn.  Didn't occur to me to try this case, initially.  Note, if you delete the shape text and re-insert the NAME() fcn, it does update and show the correct value.
Visio 2019 Pro

wapperdude

Alternative work-around...
Create a User-Defined entry, say Row_3...or something meaningful.  Do not populate the value.
In the Dbl Click event cell, enter:  =SETF(GetRef(User.Row_3),"FILENAME()")

Dbl clicking the shape will place the Filename formula into the User Defined cell.  It will catch whatever the current name of the file, even if it were a file created externally in Window Explorer.
You can field insert the UD entry as text, or use it as reference else where.
Visio 2019 Pro