• Macro to resize boxes in Visio 2007

    Author
    Topic
    #464865

    Hello,

    I have a Visio 2007 flowchart that needs to be resized.

    The flowchart is currently sized to print out as an “E” sized drawing.
    I have been asked to change the font size in all of the boxes from Arial 8pt to Arial 12pt.

    I found a macro on the web that accomplished the font size change and now I would like to change the box size to match the text size.

    Is there a macro that will change the height and width of every box size on the flowchart?

    Perhaps, there is an easier way to go about this task, such as a macro to scale the drawing proportionately….

    Any information on how best to handle this task, is appreciated.

    Regards,

    -J

    Viewing 5 reply threads
    Author
    Replies
    • #1191982

      I’m going to move this thread to the VBA forum. You are more likely to be seen by folks who can help you there.

    • #1191992


      Perhaps, there is an easier way to go about this task, such as a macro to scale the drawing proportionately….

      Have you tried simply changing the drawing scale – I don’t see why you would need a Macro to do this.

    • #1192146

      I wouldn’t use VBA for this – it is unneccessary. You can resize each shape with VBA but the connectors need to stay connected and relative positions will become a problem.

      It is easier to just group the entire drawing and drag it larger. Do this by pressing Ctrl-A then Shift-Ctrl-G. Now drag a corner diagonally to stretch the shapes larger.

      You can change the font sizes now you have all the shapes selected too although I would recommend you do this by using the Define Styles command under the Format menu.

    • #1192460

      Hello all,

      Thanks for the postings. Yes, I was aware of the Select All/Group and resize option and that is probably the best option for me, as I have a flowchart that runs from the
      top to the bottom of a E Size drawing.

      I was curious more than anything about Macros that can be used to resize boxes.

      Here is the Visio macro that resizes text, for anyone interested:

      Regards,

      -J

      http://www.vbaexpress.com/kb/getarticle.php?kb_id=507

      Option Explicit

      Public Sub FontChange()
      ‘ Change the font of all shapes to 12pt
      Dim shpObjs As Visio.Shapes
      Dim shpObj As Visio.Shape
      Dim celObj As Visio.Cell
      Dim i As Integer

      ‘Reference to Shapes collection
      Set shpObjs = ActivePage.Shapes

      ‘Loop Shapes collection to change font size
      For i = 1 To shpObjs.Count
      Set shpObj = shpObjs(i)
      Set celObj = shpObj.Cells(“Char.Size”)
      celObj.Formula = “=12 pt.”
      ‘ or
      ‘ shapeObj.Cells(“Char.Size[1] “).Formula = “= 12 pt.”
      Next

      ‘Clean up
      Set celObj = Nothing
      Set shpObj = Nothing
      Set shpObjs = Nothing
      End Sub

    • #1192620

      As an academic exercise, the code to resize the shapes and fonts can be written more succinctly. Note that the relative positions won’t change so that this is not simply zooming your graphic.

      Code:
      Sub SupersizeMe()
        Dim shpObj As Visio.Shape, dblSize as Double
        dblSize = 1.5   'the magnification factor (>1 gets bigger, <1 gets smaller)
        On Error Resume Next   'some shapes have protected properties so the code would fail
        For Each shpObj In ActivePage.Shapes
          shpObj.Cells("Width") = shpObj.Cells("Width") * dblSize 
          shpObj.Cells("Height") = shpObj.Cells("Height") * dblSize 
          shpObj.Cells("Char.Size") = shpObj.Cells("Char.Size") * dblSize 
        Next shpObj
      End Sub
    • #1222275

      Another way to do this is with the Size and Position window that you can open with the View menu. Assuming all of the boxes are the same size, you can multi-select them either with a selection fence or by Shift clicking each individual box to select the ones you want. After your selection is complete, in the Size and Position window enter the new vertical and horizontal sizes you want. Be sure you hit Enter after the last entry while your cursor is in the S&P box, and all of the shapes will change to the new dimensions.

    Viewing 5 reply threads
    Reply To: Macro to resize boxes in Visio 2007

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: