Author Topic: IF statement always evaluates as true  (Read 2077 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 2
IF statement always evaluates as true
« on: September 25, 2014, 04:32:19 PM »
I am using Visio2010's cross-functional diagrams for our process flow.  Currently, the process has hundreds of blocks most with notes attached through a hyperlink manually entered into each block.  There are two locations for notes one for editable pages and one for pdfs.  Previously, I went through each block to change path and extension for each block with note pages.  I want to automate the process since the process is going through major revisions.
I have a working copy in one location and a protected public version in another.  I am a firm believer in having separate working and final versions.

What I want
If the Visio file is opened in one location it will open the pdf version of the notes, if opened from other locations it opens the docx version.  The pdfs are in a publicly accessible location while the docx files are restricted access.

What I have done
The file name is based on text entered into the block.  Block text always starts with a predefined code.  The code is the file name.
In a User-defined cell, I extract the code using SHAPETEXT(TheText) function, then use string functions to extract just the code.
In User.NotePath, I put the formula IF(Directory()="\\IP address\Forms and Policies\Process Flow", "\\IP address\Forms and Policies\Process Flow\Notes\","\\IP address\Working Dir\Process Flow\Notes\").  It ALWAYS evaluates as true no matter what directory I open the file from, yet DIRECTORY reports the correct source path.
Another cell contains contains another IF statement to select the extension.  In yet another cell I assemble the entire path and filename. (I know this can be done in one cell but I want to see the output of each step, at least for now.)  The cell evaluating the extension selection also ALWAYS evaluates as true.  The formula I am using is IF(User.NotePath="\\IP address\Forms and Policies\Process Flow\Notes\",".docx",".pdf")
I have replaced spaces in the path with %20, added quotes, removed quotes, put the DIRECTORY() statement in its own cell and referenced that, and a few other things all to no avail.
I have other IF statements that are evaluating correctly.  These other statements turn on and off other shapes in the grouped shape and change its color based on data in the grouped shape's properties.

I am working with the shape's mastershape shapesheet.

What am I missing?  Microsoft's shapesheet help is about useless.
Is it that it cannot evaluate the \s?
Is there a solution I can use?

Thank you in advance for any assistance.


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3881
  • Ideas Visio-lized into solutions
Re: IF statement always evaluates as true
« Reply #1 on: September 25, 2014, 07:44:14 PM »
You need to use STRSAME to compare text strings.  Your formula should be something like this:  =IF(STRSAME(DIRECTORY(),"D:\dir1\dir2\"),"Right File","Wrong File")
Where the string in quotes is your desired pathname, and the right, wrong files are the complete pathnames to the files.  Note, I only checked the strsame comparison.

Visio 2019 Pro


  • Newbie
  • *
  • Posts: 2
Re: IF statement always evaluates as true
« Reply #2 on: September 26, 2014, 07:38:50 AM »
Thank you very much.  I have done lots of interesting things with strings, but this one was obviously a first for me.

It would be really nice to have a book similar to Sybex's VBA Developers Handbook for Visio to help me out in these situations, but I have not found one yet or perhaps done the correct searches.

Again, thanks.


  • Hero Member
  • *****
  • Posts: 1061
Re: IF statement always evaluates as true
« Reply #3 on: September 29, 2014, 01:55:15 AM »
Somewhat older but still a good source of knowledge:
Visio Developers Survival Kid 2003 from Graham Wiseman.