Author Topic: VBA Document_DocumentOpened event on stencil triggers only once.  (Read 19592 times)

0 Members and 1 Guest are viewing this topic.

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
I am using Visio 2016 pro for Office 365.
My stencil is saved in "My stencil" folder.
It has VBA macro only for Document_DocumentOpened event in ThisDocumemt module.
Code
Option Explicit

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
    MsgBox doc.Name & " opened!"
End Sub


When I start Visio application, create a blank new drawing, open this stencl by clicking a menu "Other Shapes"/ "My Shapes! in shapes window, then the Document_DocumentOpened event triggers normally.
But when I close this stencil and open again in the same manner, the event never triggers.

I don't remember this is the same as in previous versions of Visio.
Am I missing something important?
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Yacine

  • Hero Member
  • *****
  • Posts: 3093
Re: VBA Document_DocumentOpened event on stencil triggers only once.
« Reply #1 on: April 03, 2016, 05:39:54 AM »
Just tested: absolutely no problem with your scenario in V2013.
Yacine

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: VBA Document_DocumentOpened event on stencil triggers only once.
« Reply #2 on: April 03, 2016, 05:57:15 AM »
Thank you , Yacine.
Then it may be a bug in Visio 2016 pro for Office 365.
You had better wait buying until bug is fixed.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

JuneTheSecond

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: VBA Document_DocumentOpened event on stencil triggers only once.
« Reply #3 on: April 11, 2016, 11:40:34 PM »
Now, I am getting around this problem setting My Shapes folder as a trusted location.
I am referring to a document at https://support.office.com/en-us/article/Add-remove-or-change-a-trusted-location-7ee1cdc2-483e-4cbb-bcb3-4e7c67147fb4?ui=en-US&rs=en-US&ad=US&fromAR=1 .
But I am afread the security level is lower than before.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Visisthebest

  • Hero Member
  • *****
  • Posts: 732
Re: VBA Document_DocumentOpened event on stencil triggers only once.
« Reply #4 on: March 22, 2021, 03:31:03 AM »
JuneTheSecond did Visio open the stencil in protected mode, and was this the reason Document_DocumentOpened didn’t start when the stencil was opened?
Visio 2021 Professional