[Solved] Use a custom fill pattern from a .vssx file

Started by Kola, April 07, 2021, 02:30:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kola

Hello,
I am new here. I am working on a vba macro that changes the fill pattern of various shapes depending on their name. I made a custom stencil (named "Favoris.vssx") with various Fill Patterns ("test" for example). I am trying to use these fill patterns in other visio document. Here a part of my code that seems to work:


For Each vsoPage In vsoDoc.Pages
    Set vsoDoc = vsoApp.Documents.Open(File.Path)
    'Path of the .vssx file
    strNewPath = local_path
    Favoris = local_path & "\Favoris.vssx"
    'Loading the .vssx file in a current open visio doc
    Dim vsoDocNew As Visio.Document
    Set vsoDocNew = vsoApp.Documents.OpenEx(Favoris, visOpenDocked + visAddStencil)
    'Use the custom stencil for each shapes in the page
    For Each vsoShp1 In vsoPage.Shapes
         vsoShp1.CellsU("FillPattern").FormulaU = "USE(""test"")"
    Next
Next



The issue here, is that the shape "seems" to be filled with the fill pattern "test" but when I look at the shape, it still using the default fill pattern. When I change the fill pattern manualy, "test" is added to the Fill Patterns folders in the Drawing Explorer. But I do not know how to do that with vba. Perhaps I am missing something else...

Surrogate

For add your custom fill patterns from vssx to other vsdx document, you need drom some master-shape from stencil, which contain this fill pattern

Kola

Quote from: Surrogate on April 07, 2021, 04:46:18 PM
For add your custom fill patterns from vssx to other vsdx document, you need drom some master-shape from stencil, which contain this fill pattern
Gosh... it works. I just add this to my code:

Set mst = vsoDocNew.Masters.ItemU("test")
Set shp = vsoPage.Drop(mst, 1, 1)
shp.Delete

Thanks a lot, I would never have guessed this  :o