visio textbox resize

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • joemo2003
    New Member
    • Feb 2007
    • 142

    visio textbox resize

    I use the follow code to resize the textbox in visio, anybody know what is wrong?

    Code:
    Dim ashape as visio.shape
    ashape.CellsU("TxtWidth").Formula = "=TEXTWIDTH(TheText)"
    Thanks
  • joemo2003
    New Member
    • Feb 2007
    • 142

    #2
    or I want to maximize the textbox, so
    Code:
    ashape.Formula = "Max(TEXTWIDTH(TheText), 8 * Char.Size)"
    Any help on either way will be great.

    Comment

    • joemo2003
      New Member
      • Feb 2007
      • 142

      #3
      Originally posted by joemo2003
      or I want to maximize the textbox, so
      Code:
      ashape.Formula = "Max(TEXTWIDTH(TheText), 8 * Char.Size)"
      Any help on either way will be great.
      seem like the ashape.Formula is wrong.

      Comment

      • joemo2003
        New Member
        • Feb 2007
        • 142

        #4
        Originally posted by joemo2003
        seem like the ashape.Formula is wrong.
        that is wrong.

        Comment

        • joemo2003
          New Member
          • Feb 2007
          • 142

          #5
          Originally posted by joemo2003
          that is wrong.
          Samm help.

          Comment

          • joemo2003
            New Member
            • Feb 2007
            • 142

            #6
            Forget everthing above,

            Code:
            Dim celObjWidth As Visio.Cell
            Set celObjWidth = ashape.Cells("width")
            If ashape.Text = sFind Then
            ashape.Text = sFind & Chr(10) & sReplacement
            End if
            celObjWidth.Formula = "=GUARD(TEXTWIDTH(TheText))"
            this code actually work, but not only resize the textbox, but also resize all the other shape.

            help

            Comment

            • SammyB
              Recognized Expert Contributor
              • Mar 2007
              • 807

              #7
              Originally posted by joemo2003
              Samm help.
              :) No Visio untill tonight, 9PM EST. Can't you just record a macro in Visio that does the resize and look at the code that it generates?

              Comment

              • joemo2003
                New Member
                • Feb 2007
                • 142

                #8
                samm,
                when you have visio with you, could you test another thing for me too.
                I need to input text to visio with mutiple pages, the follow code is working for me
                Code:
                For k=1 To 5
                Set apage = vsDoc.Pages(k)
                ...
                Next k
                The thing is the code above need to tell the page number (5), but the page may be varied on other visio files, is there a code something like
                vsDoc.Pages(End )?

                thanks

                Comment

                • SammyB
                  Recognized Expert Contributor
                  • Mar 2007
                  • 807

                  #9
                  Originally posted by joemo2003
                  samm,
                  when you have visio with you, could you test another thing for me too.
                  I need to input text to visio with mutiple pages, the follow code is working for me
                  Code:
                  For k=1 To 5
                  Set apage = vsDoc.Pages(k)
                  ...
                  Next k
                  The thing is the code above need to tell the page number (5), but the page may be varied on other visio files, is there a code something like
                  vsDoc.Pages(End )?

                  thanks
                  For width & height, this works for me:
                  Code:
                  If s.Text = sFind Then
                  	s.Text = sReplacement
                  	s.Cells("Height").Formula = "40mm"
                  	s.Cells("Width").Formula = "60mm"
                  End If
                  For number of pages, just use Pages.Count:
                  Code:
                  MsgBox vsDoc.Pages.Count
                  Set vsLastPage = vsDoc.Pages(vsDoc.Pages.Count)

                  Comment

                  • joemo2003
                    New Member
                    • Feb 2007
                    • 142

                    #10
                    Do u still remember the resize text font you help me before?
                    Code:
                    ashape.Text = sFind & Chr(10) & sReplacement
                    This time I only want to resize the sReplacement, but not the sFind,
                    If i use
                    Code:
                    Dim aCell As Visio.Cell
                    Set aCell = ashape.Text("Char.size")
                    aCell.Formula="12pt"
                    it will resize include the sFind. So how to resize partially?
                    thanks

                    Comment

                    • SammyB
                      Recognized Expert Contributor
                      • Mar 2007
                      • 807

                      #11
                      Originally posted by joemo2003
                      Do u still remember the resize text font you help me before?
                      Code:
                      ashape.Text = sFind & Chr(10) & sReplacement
                      This time I only want to resize the sReplacement, but not the sFind,
                      If i use
                      Code:
                      Dim aCell As Visio.Cell
                      Set aCell = ashape.Text("Char.size")
                      aCell.Formula="12pt"
                      it will resize include the sFind. So how to resize partially?
                      thanks
                      You use the Characters object:
                      Code:
                      	Dim s As String, i As Integer
                      	s = "Not Fun"
                      	Dim c As Characters
                      	Set c = ActivePage.Shapes(1).Characters
                      	i = InStr(c.Text, s)
                      	c.Begin = i - 1
                      	c.End = i - 1 + Len(s)
                      	c.CharProps(visCharacterSize) = 16
                      	c.CharProps(visCharacterStyle) = visBold + visItalic
                      	c.CharProps(visCharacterColor) = visRed
                      In this example, "Not Fun" is your replacement text. It is set to 16 point, bold, italic, & red. HTH --Sam

                      Comment

                      • SammyB
                        Recognized Expert Contributor
                        • Mar 2007
                        • 807

                        #12
                        BTW, I found a Web Site with info on Visio programming! See http://www.design-drawing.com/visio/.

                        Also, a DoCMD reference, http://www.mster.co.jp/visiosquare/c...2/index01.html

                        So, if I learn Jananese, I can be really dangerous! ;)

                        Comment

                        • SammyB
                          Recognized Expert Contributor
                          • Mar 2007
                          • 807

                          #13
                          Also, a book:
                          Learn Microsoft Visio 2002 for the Advanced User by Ralph Grabowski and Frank Zander

                          Comment

                          • joemo2003
                            New Member
                            • Feb 2007
                            • 142

                            #14
                            Originally posted by SammyB
                            You use the Characters object:
                            Code:
                            	Dim s As String, i As Integer
                            	s = "Not Fun"
                            	Dim c As Characters
                            	Set c = ActivePage.Shapes(1).Characters
                            	i = InStr(c.Text, s)
                            	c.Begin = i - 1
                            	c.End = i - 1 + Len(s)
                            	c.CharProps(visCharacterSize) = 16
                            	c.CharProps(visCharacterStyle) = visBold + visItalic
                            	c.CharProps(visCharacterColor) = visRed
                            In this example, "Not Fun" is your replacement text. It is set to 16 point, bold, italic, & red. HTH --Sam
                            I use
                            Code:
                            For Each ashape In apage.Shapes 
                            ...
                            Set c = ashape.Characters
                            ...
                            next ashape
                            when I debug it, that "ashape.Charact ers" return nothing. It said "type mismatch". Why is that happen?

                            Comment

                            • joemo2003
                              New Member
                              • Feb 2007
                              • 142

                              #15
                              Originally posted by joemo2003
                              I use
                              Code:
                              For Each ashape In apage.Shapes 
                              ...
                              Set c = ashape.Characters
                              ...
                              next ashape
                              when I debug it, that "ashape.Charact ers" return nothing. It said "type mismatch". Why is that happen?
                              Well, the "ashape.Charact ers" do return something, but the "c" is empty.

                              Comment

                              Working...