visio textbox resize

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    #16
    Originally posted by joemo2003
    Well, the "ashape.Charact ers" do return something, but the "c" is empty.
    Remember, you are in a multiple application world (Excel & Visio). c should be Dim'ed as Visio.Character s. My sample was just a Visio macro. Keep :)!

    Comment

    • joemo2003
      New Member
      • Feb 2007
      • 142

      #17
      Originally posted by SammyB
      Remember, you are in a multiple application world (Excel & Visio). c should be Dim'ed as Visio.Character s. My sample was just a Visio macro. Keep :)!
      great, that work. One more question, how to use the SaveAsEx function?
      I try to save the same file name with extension date and time, but all I know is use the vsDoc.save or vsApp.DoCmd(vis CmdFileSave).

      Comment

      • SammyB
        Recognized Expert Contributor
        • Mar 2007
        • 807

        #18
        Originally posted by joemo2003
        great, that work. One more question, how to use the SaveAsEx function?
        I try to save the same file name with extension date and time, but all I know is use the vsDoc.save or vsApp.DoCmd(vis CmdFileSave).
        Code:
        	Dim sNew As String
        	sNew = Split(ActiveDocument.Name, ".")(0) ' Strip filetype
        	sNew = sNew & "-" & Format(Now(), "yyyy-mm-dd") & ".vsd"
        	MsgBox "Saving chart as readonly in " & sNew
        	ActiveDocument.SaveAsEx sNew, visSaveAsRO

        Comment

        • joemo2003
          New Member
          • Feb 2007
          • 142

          #19
          great, everthing work good. hopefully my boss will like it. Thanks, sam

          Comment

          • joemo2003
            New Member
            • Feb 2007
            • 142

            #20
            I think the use the DoCmd to open visio is simpler than the one you help me before.
            Code:
            Set vsApp = New Visio.Application
            vsApp.DoCmd (visCmdFileOpen)
            the code work for select and open the visio, but error occur when click cancel.
            How can I make the cancel work too?

            Comment

            • SammyB
              Recognized Expert Contributor
              • Mar 2007
              • 807

              #21
              Originally posted by joemo2003
              I think the use the DoCmd to open visio is simpler than the one you help me before.
              Code:
              Set vsApp = New Visio.Application
              vsApp.DoCmd (visCmdFileOpen)
              the code work for select and open the visio, but error occur when click cancel.
              How can I make the cancel work too?
              It's not simpler if it doesn't work. Use Excel.GetOpenFi lename and make the response a Variant. If the user presses Cancel, then the Variant is False. Weird, but standard Microsoft:
              Code:
              	Dim vFile As Variant
              	vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
              	If vFile = False Then Exit Sub
              	MsgBox "Open Visio file, " & vFile
              You can get DoCmd to work, but it's not pretty.
              Code:
              	Dim vsApp As Visio.Application
              	Dim vsDoc As Visio.Document
              	Set vsApp = CreateObject("Visio.Application")
              	On Error GoTo PressedCancel
              	vsApp.DoCmd (visCmdFileOpen)
              	On Error GoTo 0				 ' Resume normal error processing
              	Set vsDoc = vsApp.ActiveDocument
              	MsgBox "Continue Processing..."
              	Exit Sub
              PressedCancel:
              	vsApp.Quit

              Comment

              • joemo2003
                New Member
                • Feb 2007
                • 142

                #22
                Originally posted by SammyB
                It's not simpler if it doesn't work. Use Excel.GetOpenFi lename and make the response a Variant. If the user presses Cancel, then the Variant is False. Weird, but standard Microsoft:
                Code:
                	Dim vFile As Variant
                	vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
                	If vFile = False Then Exit Sub
                	MsgBox "Open Visio file, " & vFile
                You can get DoCmd to work, but it's not pretty.
                Code:
                	Dim vsApp As Visio.Application
                	Dim vsDoc As Visio.Document
                	Set vsApp = CreateObject("Visio.Application")
                	On Error GoTo PressedCancel
                	vsApp.DoCmd (visCmdFileOpen)
                	On Error GoTo 0				 ' Resume normal error processing
                	Set vsDoc = vsApp.ActiveDocument
                	MsgBox "Continue Processing..."
                	Exit Sub
                PressedCancel:
                	vsApp.Quit
                The reason I want to use the DoCmd is it pass te fully path and filename to the opened file, but GetOpenFilename does not. Thanks a lot, that DoCmd is working now.

                Comment

                • joemo2003
                  New Member
                  • Feb 2007
                  • 142

                  #23
                  Sam, help again.

                  In commondbutton1, I have
                  Code:
                  Dim vsDocs As Visio.Documents
                  Dim vsDoc As Visio.Document
                  Set vsDocs = vsApp.Documents
                  Set vsDoc = vsDocs.Open("D:\folderxx\test.vsd")
                  Set vsDoc = vsApp.ActiveDocument
                  vsApp.Visible = False
                  in commondbutton 2, I have
                  Code:
                  sNew = Split(vsDoc.Name, ".")(0)
                  sNew = sNew & "(" & Format(Now(), "MM_dd_yyyy") & ".vsd"
                  vsApp.ActiveDocument.SaveAsEx sNew, visSaveAsRO
                  vsApp.quit
                  When it save the file, it lost the path and save to a temporally folder in C: drive, how to make it save to where the file come from (the D: drive)? It save back to D: drive when I use the DoCmd(visCmdFil eOpen), but this time I need to specified the file name in the code.

                  Comment

                  • SammyB
                    Recognized Expert Contributor
                    • Mar 2007
                    • 807

                    #24
                    Visio.ActiveDoc ument.Path

                    Comment

                    • joemo2003
                      New Member
                      • Feb 2007
                      • 142

                      #25
                      Originally posted by SammyB
                      Visio.ActiveDoc ument.Path
                      I still cannot figure out how to use the path function. can you specify little bit more?

                      Comment

                      • SammyB
                        Recognized Expert Contributor
                        • Mar 2007
                        • 807

                        #26
                        Originally posted by joemo2003
                        I still cannot figure out how to use the path function. can you specify little bit more?
                        Putting the Open/Close all together, I have:
                        Code:
                         Sub OpenExisting()
                        	Dim vsApp As Visio.Application
                        	Dim vsDoc As Visio.Document
                        	Set vsApp = CreateObject("Visio.Application")
                        	On Error GoTo PressedCancel
                        	vsApp.DoCmd (visCmdFileOpen)
                        	On Error GoTo 0			 ' Resume normal error processing
                        	Set vsDoc = vsApp.ActiveDocument
                        	MsgBox "Continue Processing..."
                        	Dim sNew As String
                        	sNew = Split(vsDoc.Name, ".")(0)
                        	sNew = sNew & "-" & Format(Now(), "MM_dd_yyyy") & ".vsd"
                        	vsApp.ActiveDocument.SaveAsEx vsDoc.Path & sNew, visSaveAsRO
                        	vsApp.Quit
                        PressedCancel:
                        	vsApp.Quit
                        End Sub
                        Is that clear or is there something that needs explanation? BTW When you run a macro, you can press the "Step Into" button and step through your code with the F8 key. As you step through it, when you hover the mouse over a property or variable, the IDE shows you the value. It really helps to understand/debug. Also, you can click on a variable, and use the menu Debug, Add Watch. For example, after "Set vsDoc = vsApp.ActiveDoc ument", if you set a watch on vsDoc, then by clicking on the plus signs, you can see all of the current properties of the document. --Sam

                        Comment

                        • joemo2003
                          New Member
                          • Feb 2007
                          • 142

                          #27
                          Originally posted by SammyB
                          Putting the Open/Close all together, I have:
                          Code:
                           Sub OpenExisting()
                          	Dim vsApp As Visio.Application
                          	Dim vsDoc As Visio.Document
                          	Set vsApp = CreateObject("Visio.Application")
                          	On Error GoTo PressedCancel
                          	vsApp.DoCmd (visCmdFileOpen)
                          	On Error GoTo 0			 ' Resume normal error processing
                          	Set vsDoc = vsApp.ActiveDocument
                          	MsgBox "Continue Processing..."
                          	Dim sNew As String
                          	sNew = Split(vsDoc.Name, ".")(0)
                          	sNew = sNew & "-" & Format(Now(), "MM_dd_yyyy") & ".vsd"
                          	vsApp.ActiveDocument.SaveAsEx vsDoc.Path & sNew, visSaveAsRO
                          	vsApp.Quit
                          PressedCancel:
                          	vsApp.Quit
                          End Sub
                          Is that clear or is there something that needs explanation? BTW When you run a macro, you can press the "Step Into" button and step through your code with the F8 key. As you step through it, when you hover the mouse over a property or variable, the IDE shows you the value. It really helps to understand/debug. Also, you can click on a variable, and use the menu Debug, Add Watch. For example, after "Set vsDoc = vsApp.ActiveDoc ument", if you set a watch on vsDoc, then by clicking on the plus signs, you can see all of the current properties of the document. --Sam
                          thanks, that help a lot.

                          Comment

                          • joemo2003
                            New Member
                            • Feb 2007
                            • 142

                            #28
                            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

                            Sam, do you still remember this code? It's on page 2. Is there anyway to break down the replacement text and set to difference size? Just like in your code, s="Not Fun", how to make "Not" to size 16, and "Fun" to size 10. The condition is the "Not" in one row, and the "Fun" in another row.

                            Thanks

                            Comment

                            • SammyB
                              Recognized Expert Contributor
                              • Mar 2007
                              • 807

                              #29
                              Originally posted by joemo2003
                              Sam, do you still remember this code? It's on page 2. Is there anyway to break down the replacement text and set to difference size? Just like in your code, s="Not Fun", how to make "Not" to size 16, and "Fun" to size 10. The condition is the "Not" in one row, and the "Fun" in another row.

                              Thanks
                              So, you want the first row of text to be 16 and the second row to be 10 for all of your Visio shapes? In that case, I would just iterate through all of the Visio shapes after you've done the replacement.

                              Comment

                              • joemo2003
                                New Member
                                • Feb 2007
                                • 142

                                #30
                                Originally posted by SammyB
                                So, you want the first row of text to be 16 and the second row to be 10 for all of your Visio shapes? In that case, I would just iterate through all of the Visio shapes after you've done the replacement.
                                yeah, but only to the replacement text.

                                Comment

                                Working...