Move object to center of visible area

Hello,

When a file is imported (via VBA code) it is placed in center of page.

How do I import/move the objects to center of currently visible area?

Thanks.

Parents
  • You could use ActiveWindow.ActiveView.GetViewArea to get the location and dimensions of the view area, and then reposition objects using that information. One example:

    Sub center_selected_to_view()
    
    Dim dblX As Double
    Dim dblY As Double
    Dim dblW As Double
    Dim dblH As Double
    Dim sr As ShapeRange
    
        ActiveWindow.ActiveView.GetViewArea dblX, dblY, dblW, dblH
        
        Set sr = ActiveSelectionRange
        sr.CenterX = dblX + dblW / 2
        sr.CenterY = dblY + dblH / 2
        
    End Sub
    
Reply Children
No Data