Re: How do I activate a stencil that is already open?
- From: "John Goldsmith" <FirstName.LastName@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 16 Oct 2007 17:12:46 +0100
Hello Jason,
Glad that's helped. Re running your code all from Excel, you might find
this link helpful:
http://support.microsoft.com:80/kb/309603
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
"Jason V" <JasonV@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:85E3E9BE-8B0E-43D5-A84F-E667E44AEB5A@xxxxxxxxxxxxxxxx
Thanks John. I understand this better now.
In regards to your answer to my last question. Myabe I don't need any code
in Visio. I would rather not I just did't know how. What I am doing is
getting information from a user in excel and then drawing the object in
visio, and then copying it back to the excel form transparent to the user
and
they can see their system get built and then if they need to later modify
the
visio file. I am calling a routine in Visio but I quess I could have all
of
that code in excel? correct? I just didn't think about that.
--
Jason V
"John Goldsmith" wrote:
Morning Jason,
Answers are below.
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
"Jason V" <JasonV@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7B7545C0-0C64-4D3A-97D0-9A6D7F4E14F8@xxxxxxxxxxxxxxxx
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
--
Jason V
"John Goldsmith" wrote:
Hello Jason,
Have a go with this:
Public Sub TestDropShapeX()
Dim stencil As Visio.Document
Dim mstCircle As Visio.Master
Dim vDoc As Visio.Document
Dim sStencilPath As String
Dim sStencilName As String
Dim sStencil As String
Dim shpNew As Visio.Shape
sStencilPath = "d:\"
sStencilName = "ABC.vss"
'Check if the stencil is already open...
For Each vDoc In Application.Documents
If vDoc.Name = sStencilName Then
Set stencil = vDoc
End If
Next vDoc
'...if not, open it
If stencil Is Nothing Then
sStencil = sStencilPath & sStencilName
Set stencil = Documents.OpenEx( _
sStencil, visOpenDocked)
End If
'Note - Activating the stencil is not required
'to drop the shape
ActiveWindow.Windows.ItemEx(stencil.Title).Activate
Set mstCircle = stencil.Masters("ee")
Set shpNew = ThisDocument.Pages(1).Drop(mstCircle, 6, 6)
End Sub
If you have any errors let me know on which line and what they say.
Hope that helps.
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
"Jason V" <JasonV@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:298F3828-8C3A-49C6-815F-A9D61CE9C651@xxxxxxxxxxxxxxxx
Thanks. However when I try it I get an error. Here is what I am
after.
The following code works but it opens ABC.vss, but I already have it
open.
How can I modify this to just activate the one that is open and drop
a
shape
from it?
Public Sub TestDropShapeX()
Dim stencil As Visio.Document, mstCircle As Visio.Master
Set stencil =
ThisDocument.Application.Documents.Open("d:\...\ABC.vss")
ThisDocument.Application.Windows(ThisDocument.Index).Activate
Set mstCircle = stencil.Masters("ee") ' Get the master named "ee"
and
drop
that shape on the page!
ThisDocument.Pages(1).Drop ShapeName, 6, 6
End Sub
Thanks
--
Jason V
"John Goldsmith" wrote:
Hello Jason,
Just use the Activate method of the window object. For example:
ActiveWindow.Windows.ItemEx("Basic Flowchart Shapes
(Metric)").Activate
Best regards
John
John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
"Jason V" <JasonV@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:477C4D0D-D4F9-431F-9898-8F0B6FFEE168@xxxxxxxxxxxxxxxx
How do I activate a stencil that is already open?
--
Jason V
.
- References:
- Re: How do I activate a stencil that is already open?
- From: John Goldsmith
- Re: How do I activate a stencil that is already open?
- From: John Goldsmith
- Re: How do I activate a stencil that is already open?
- From: Jason V
- Re: How do I activate a stencil that is already open?
- From: John Goldsmith
- Re: How do I activate a stencil that is already open?
- From: Jason V
- Re: How do I activate a stencil that is already open?
- Prev by Date: Re: How do I activate a stencil that is already open?
- Next by Date: Re: Reversed Engineered Table graphic size
- Previous by thread: Re: How do I activate a stencil that is already open?
- Next by thread: Re: FileDialog Method not supported?
- Index(es):
Relevant Pages
|