When Logic fails?

Started by jik_ff, June 09, 2017, 02:42:51 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jik_ff

I have a drawing that allows the import of a background map.  The drawing itself is landscape, so to optimize space, I have it check to see if the imported map file.  So after importing the file, I do this:

    newShp.Name = "PageMap"
    'move it to the back.  This is where is should be.
    newShp.SendToBack

    'Should set the map to fit the page, grab the width and height cells
    Set wCell = newShp.Cells("Width")
    Set hCell = newShp.Cells("Height")
    'will need to rescale to as close to 34(h)x44(w) as possible
   
    'check if image imported is landscape or portrait
    If hCell.Formula > wCell.Formula Then
        'must be landscape for the mapping to work well.
       
        Debug.Print "Height was " & hCell.Formula
        Debug.Print "Width was " & wCell.Formula


So logically if hCell.Formula is less than wCell.Formula, then the debug code (and rotation code that follows) should not run.  In the past, things have run fine, but today it's rotating a landscape image.  The debug output shows that it should not be:
Height was 7.2500147501928 in.
Width was 11.000022379603 in.

I know what you are thinking.  Just throw in the file portait, and it should rotate it back to landscape.  Well it doesn't.  Can anyone explain this?

Yacine

hcell.formula is a string! Most the time you get correct answers, but here is how you should read the value: https://msdn.microsoft.com/de-de/library/office/ff766514.aspx

Yacine

jik_ff

#2
ah...  damn.  Guess I have just been lucky up to this point.  I now store it in a double for the test.  Works now.  Thanks.

wapperdude

Instead of inserting onto the drawing page, you ought consider adding it to a background page, and then set the drawing page to view the background page.  It will make selecting shapes on the drawing page easier, without having to worry about selecting the map.

The macro recorder out to capture all of the necessary steps which can be pasted at the beginning of your macro.

Wapperdude
Visio 2019 Pro