Author Topic: FILENAME() Shapesheet function does not update  (Read 4210 times)

0 Members and 1 Guest are viewing this topic.

huever

  • Newbie
  • *
  • Posts: 6
FILENAME() Shapesheet function does not update
« on: October 15, 2019, 01:42:09 AM »
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

  • Hero Member
  • *****
  • Posts: 1389
    • ShapeSheet™ Knowledge Base
Re: FILENAME() Shapesheet function does not update
« Reply #1 on: October 15, 2019, 08:51:10 AM »
Why you ask about this issue in Programming and code chapter?
You can use vsd-documents, why you need save it in vsdx?

huever

  • Newbie
  • *
  • Posts: 6
Re: FILENAME() Shapesheet function does not update
« Reply #2 on: October 15, 2019, 11:05:23 AM »
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

  • Hero Member
  • *****
  • Posts: 1589
Re: FILENAME() Shapesheet function does not update
« Reply #3 on: October 15, 2019, 11:24:22 AM »
probably should try DEPENDSON to trigger filename() refresh

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

Yacine

  • Hero Member
  • *****
  • Posts: 2747
Re: FILENAME() Shapesheet function does not update
« Reply #4 on: October 15, 2019, 12:33:58 PM »
@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.
« Last Edit: October 15, 2019, 12:38:19 PM by Yacine »
Yacine

Surrogate

  • Hero Member
  • *****
  • Posts: 1389
    • ShapeSheet™ Knowledge Base
Re: FILENAME() Shapesheet function does not update
« Reply #5 on: October 15, 2019, 03:03:43 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4090
  • Ideas Visio-lized into solutions
Re: FILENAME() Shapesheet function does not update
« Reply #6 on: October 15, 2019, 07:54:43 PM »
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

  • Newbie
  • *
  • Posts: 6
Re: FILENAME() Shapesheet function does not update
« Reply #7 on: October 16, 2019, 12:52:02 AM »
"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

  • Sr. Member
  • ****
  • Posts: 280
    • Visioport
Re: FILENAME() Shapesheet function does not update
« Reply #8 on: October 16, 2019, 02:50:44 AM »
Quote
Correcting 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
« Last Edit: October 16, 2019, 03:02:21 AM by Croc »

Croc

  • Sr. Member
  • ****
  • Posts: 280
    • Visioport
Re: FILENAME() Shapesheet function does not update
« Reply #9 on: October 16, 2019, 04:19:35 AM »
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.
Code
Private Sub Document_DocumentOpened (ByVal doc As IVDocument)
    ActiveDocument.DocumentSheet.Cells ("User.FileName"). FormulaU = """FILENAME ()"""
    ActiveDocument.DocumentSheet.Cells ("User.FileName"). FormulaU = "FILENAME ()"
End sub
« Last Edit: October 16, 2019, 07:10:30 AM by Croc »

vojo

  • Hero Member
  • *****
  • Posts: 1589
Re: FILENAME() Shapesheet function does not update
« Reply #10 on: October 16, 2019, 07:48:02 AM »
have fun

works on 2013

huever

  • Newbie
  • *
  • Posts: 6
Re: FILENAME() Shapesheet function does not update
« Reply #11 on: October 16, 2019, 11:38:13 AM »
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

  • Sr. Member
  • ****
  • Posts: 280
    • Visioport
Re: FILENAME() Shapesheet function does not update
« Reply #12 on: October 16, 2019, 01:25:20 PM »
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 :)

Code
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)
« Last Edit: October 16, 2019, 01:28:23 PM by Croc »

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4090
  • Ideas Visio-lized into solutions
Re: FILENAME() Shapesheet function does not update
« Reply #13 on: October 16, 2019, 01:40:09 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4090
  • Ideas Visio-lized into solutions
Re: FILENAME() Shapesheet function does not update
« Reply #14 on: October 17, 2019, 12:19:29 AM »
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