String Compare? RRS feed

  • Question

  • I'm trying to use VBA to adjust the dimensions of a subshape based on whether or not a cell in the shapesheet (coming from a linked record) has content.  Basically, if there's text in the cell, then the subshape needs to be wider, and if the value of the cell is "", then the subshape needs to be very, very narrow.

    The first thing I do is go through and count how many cells have content (there could be as many as nine).  But for some reason, my macro can't distinguish between "" and something with text.  I've tried

    TheShape.Cells("Prop._VisDM_Network_6").Formula <> ""

    which returns TRUE, even when it *is* equal to ""


    StrComp(TheShape.Cells("Prop._VisDM_Network_9").Formula, """", vbTextCompare)

    which returns 1, when it should be returning 0.  (I've also tried it with just a pair of quotes instead of all 4, to no avail.

    How can I check for the "" in the shapesheet?


    • Moved by Max Meng Friday, August 19, 2011 4:18 AM (From:Visio General Questions and Answers for IT Professionals)
    Thursday, August 18, 2011 10:08 PM


  • Hello,

    I'd try to assign TheShape.Cells("Prop._VisDM_Network_6").Formula to a variable dimmed as string and then use that variable in code. Instead of comparing it with "", you can use Len(theVariable) <> 0.

    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    • Marked as answer by Bruce Song Thursday, September 1, 2011 7:59 AM
    Friday, August 19, 2011 6:13 PM