View Single Post
  #2  
Old 07-07-2008, 15:43
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,787
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default A little time...

I have only had a little time to play with this, so my solution doesn't work 100%, but it may give you a direction. (Sorry but summer classes are just eating my time!)

I am attaching a GMS of what I have so far. The code looks like this:
Code:
Private Sub GlobalMacroStorage_SelectionChange()
    If frmUnits.Visible = True Then 'Check to see if form is running
        If ActiveSelection.Shapes.Count > 0 Then 'If there is a selection update Units
            frmUnits.UpdateUnits
        Else 'If no selection clear labels
            If frmUnits.lblWidthHeight.Caption <> "" Then frmUnits.lblWidthHeight.Caption = ""
            If frmUnits.lblCenter.Caption <> "" Then frmUnits.lblCenter.Caption = ""
        End If
    End If
End Sub
Wasn't not sure the best way to tell if the userform was running, sometimes this works, sometimes you might get an error.
Code:
Private Sub UserForm_Initialize()
    If ActiveShape Is Nothing Then
        If frmUnits.lblWidthHeight.Caption <> "" Then frmUnits.lblWidthHeight.Caption = ""
        If frmUnits.lblCenter.Caption <> "" Then frmUnits.lblCenter.Caption = ""
    Else
        UpdateUnits
    End If
End Sub

Sub UpdateUnits()
    Dim w As Double, h As Double
    Dim cx As Double, cy As Double
    
    Dim d As Document, s As Shape
    Set d = ActiveDocument
    Set s = ActiveShape
    
    If d.Rulers.HUnits = cdrInch Then
        s.GetSize w, h
        w = d.FromUnits(w, cdrMillimeter)
        h = d.FromUnits(h, cdrMillimeter)
        lblWidthHeight.Caption = "Width: " & Round(w, 3) & " mm" & " Height: " & Round(h, 3) & " mm"
        cx = s.CenterX
        cy = s.CenterY
        cx = d.FromUnits(cx, cdrMillimeter)
        cy = d.FromUnits(cy, cdrMillimeter)
        lblCenter.Caption = "Center: (" & Round(cx, 3) & " ," & Round(cy, 3) & ") millimeters"
    ElseIf d.Rulers.HUnits = cdrMillimeter Then
        s.GetSize w, h
        w = d.FromUnits(w, cdrInch)
        h = d.FromUnits(h, cdrInch)
        lblWidthHeight.Caption = "Width: " & Round(w, 3) & " in" & " Height: " & Round(h, 3) & " in"
        cx = s.CenterX
        cy = s.CenterY
        cx = d.FromUnits(cx, cdrInch)
        cy = d.FromUnits(cy, cdrInch)
        lblCenter.Caption = "Center: (" & Round(cx, 3) & " ," & Round(cy, 3) & ") inches"
    End If
End Sub
i will play with this a bit more as I have time, again hopefully it at least gets you started.

-Shelby
Attached Images
 
Attached Files
File Type: gms slm_Units.gms (34.0 KB, 11 views)
Reply With Quote