Add text with a userform in Visio

Started by Dusty_Rhodes, December 12, 2018, 01:47:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dusty_Rhodes

Hello i am pretty new to the Visio game and the coding side is really giving me alot of headaces since it is so much different than coding in Excel. I have created a titleblock and added a revision field. My primary problem is that i would need to make a user from that u can fill freeform text into for example your name, what have been doine to the drawing and things like that. But i cant figure out how to make it work. i can easily code and decide i want the text "Hello World" writen there but i need the text to be editable trough the userform. Can anyone help ? I am really lost

metuemre

Hi Dusty_Rhodes,

Attached is a title block example that I use for my drawings. Title block button in the custom ribbon will call the userform that can be used to enter data. Title block shapes are placed in Background page. When you need a new page, you can use duplicate command instead of new page command in order to have page title and page number shapes in the new page.

Feel free to ask if you have any questions.
Cheers,
Emre


Dusty_Rhodes

Hello metuemre thx for the template. I had gotten the shapes on my titleblock  editable with the code down below. It is not as pretty and readable as your code so i think i will change it to something more like the code u have writen. I have another question, how did u get the Titleblock button to be appart on the ribbon ?  i see that when i try to edit the ribbon the titleblock tab is there and i am able to put it into the ribbon. How do i make it so my macros also can be added to the ribbon ?

Private Sub DocumentID()
'Enable diagram services
    Dim DiagramServices As Integer
    DiagramServices = ActiveDocument.DiagramServicesEnabled
    ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150

    Application.ActiveWindow.Page = Application.ActiveDocument.Pages.ItemU("Frame ")

    Application.ActiveWindow.SetViewRect 1.223285, 10.362767, 15.396513, 10.404949

    Application.ActiveWindow.SetViewRect 5.92126, 6.433071, 8.622048, 5.826772

    Application.ActiveWindow.SetViewRect 7.023114, 5.461011, 6.953264, 4.69901

    Dim vsoCharacters1 As Visio.Characters
    Set vsoCharacters1 = Application.ActiveWindow.Page.Shapes.ItemFromID(193).Characters
    vsoCharacters1.Begin = 0
    vsoCharacters1.End = 100
    vsoCharacters1.Text = Documentclasstxt.Value

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices
End Sub

metuemre

Hi Dusty_Rhodes,

Custom ribbon is created via VBA code. See the Ribbon class in the file. You can add your buttons and call your macros like I did in the example.

Dusty_Rhodes

How did u get the button added to the ribbon ?


Dusty_Rhodes

Yeah it is probably me that is to unfamiliar with the coding side of things i have been trying for a few days to get the ribbon to work but with no succes. Does anyone know of some more detailed instruction video or anything else that could help ?

Surrogate

Quote from: Dusty_Rhodes on December 27, 2018, 06:23:35 AMDoes anyone know of some more detailed instruction video or anything else that could help ?
Not sure that we have videos about how create ribbon in Visio. But you can find some videos about other MS Office applications.

PS I am don't see these videos, because I prefer long-read articles   :)