Morning Jason,
Answers are below.
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
Jason V said:
Thanks. I got this to work however I had to rem out the line of code
ActiveWindow.Windows.ItemEx(stencil.Title).Activate
this gave me the error
Invalid window type for this action.
My mistake. A more robust method would be to replace that line with the
following:
'Note - Activating the stencil is not required
'to drop the shape
Dim wdw As Window
Application.Windows(ThisDocument.Index).Activate
For Each wdw In ActiveWindow.Windows
If wdw.Document.Name = sStencilName Then
wdw.Activate
Exit For
End If
Next wdw
In regards to not needing to activate the stencil and the stencil is
already
open along with others how does it know which stencil the shape is in?
When I
executed the previous code I supplied w/o specifically opening a new
stencil
even with a current one open I got an error on this line
Set mstCircle = stencil.Masters("ee")
object variable not set.
That's because you didn't set the reference to the stencil object first.
You need to get the stencil by either finding it already open or opeing a
new one and set a reference in either case. If you see my code below that's
what happens. When you declare an reference type object (Dim stencil as
Visio.Document) its value at that point is 'Nothing', so if our first run
('Check if the stencil is already open...) doesn't find the stencil, then
"stencil = Nothing". The second part checks whether that's the case. (If
stencil Is Nothing then open a new version.)
One more thing. I am opening Visio from excel and keeping Vision Hid
(transparent to the user). Problem is it comes up with the "do you want to
enable macros?". Is there anyway to get rid of this as I would like it to
be
totally transparent to the user?
You can surpress some dialogs but not that one as it depends on the user's
security settings. If you're running from Excel though, do you need to have
any code in the Visio document?
Hope that helps.
John