Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
other
informationbridge
office.intranets
office.misc
office.setup
office.xml
officeupdate
onenote
photodraw.discussion
powerpoint
producer
proj.standard&server
project
project.developer
project.pro_and_serve
project.server
project.vba
project2000
publisher
publisher.prepress
publisher.programming
publisher.webdesign
visio
visio.createshapes
visio.database.modeling
visio.dev.diagrams
visio.dev.shapesheet
visio.dev.vba
visio.dev.vc
visio.developer
visio.general
visio.installation
visio.printing
visio.software.modeling
visio.troubleshoot
  
 
date: Fri, 8 Jul 2005 12:45:02 -0700,    group: microsoft.public.visio.createshapes        back       


Adding a shape on a drawing to a stencil   
I now have a bunch of shapes on a drawing that were generated through VBA.  I 
now want them to become Masters in a new stencil.  I cannot figure out how to 
programatically add the existing shapes to a stencil though.  Is it even 
possible or do I need to go about it another way?  Every thing I find 
involves doing it by doing:
set master1 = mydocument.masters.add, but this method doesn't seem possible 
the way I am doing it because my shapes are created after grouping multiple 
shapes together and adding properties to them.  Code snippit below, using 
VISIO 2000.  I need to somehow add sCurShape to a new stencil

    vA.ActiveWindow.Group
    Set sCurShape = vA.ActiveWindow.Selection(1)
    
    sCurShape.Name = xlws.Range("A1").offset(lPolygons, 6).Value & "_"
    
    sCurShape.AddNamedRow Visio.visSectionProp, "Name", 0
    sCurShape.Cells("Prop.Name.Label").Formula = """Name"""
    sCurShape.Cells("Prop.Name.Format").Formula = """@"""
    sCurShape.Cells("Prop.Name.Type").Formula = 0
    sCurShape.Cells("Prop.Name.Value").Formula = """" & 
xlws.Range("A1").offset(lPolygons, 6).Value & """"
date: Fri, 8 Jul 2005 12:45:02 -0700   author:   adb

Re: Adding a shape on a drawing to a stencil   
I do not have much time to respond tonight, but the code should look 
something like
Dim docObj As Visio.Document

Dim mastersObj As Visio.Masters

Dim masterObj As Visio.Master

Set docObj = Documents.Add("")
Set mastersObj = docObj.Masters

Set masterObj = mastersObj.Add

masterObj.Name = "test"



--->You need to add your shape to the mastersObj collection.

FullFileName = "C:\My Documents\Visio\test1\temp1.vss"
docObj.SaveAs FullFileName

docObj.Close

A key thing to remember is that there is only one Visio file format, the 
extension vss, vsd, vst tells Visio how to open the file.  So you can create 
a stencil by saving a drawing as a vsd then renaming it to a vss.

John...    Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples?   http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
"adb"  wrote in message 
news:A5EADB04-C311-48BE-A1A9-6AA316C040B1@microsoft.com...
>I now have a bunch of shapes on a drawing that were generated through VBA. 
>I
> now want them to become Masters in a new stencil.  I cannot figure out how 
> to
> programatically add the existing shapes to a stencil though.  Is it even
> possible or do I need to go about it another way?  Every thing I find
> involves doing it by doing:
> set master1 = mydocument.masters.add, but this method doesn't seem 
> possible
> the way I am doing it because my shapes are created after grouping 
> multiple
> shapes together and adding properties to them.  Code snippit below, using
> VISIO 2000.  I need to somehow add sCurShape to a new stencil
>
>    vA.ActiveWindow.Group
>    Set sCurShape = vA.ActiveWindow.Selection(1)
>
>    sCurShape.Name = xlws.Range("A1").offset(lPolygons, 6).Value & "_"
>
>    sCurShape.AddNamedRow Visio.visSectionProp, "Name", 0
>    sCurShape.Cells("Prop.Name.Label").Formula = """Name"""
>    sCurShape.Cells("Prop.Name.Format").Formula = """@"""
>    sCurShape.Cells("Prop.Name.Type").Formula = 0
>    sCurShape.Cells("Prop.Name.Value").Formula = """" &
> xlws.Range("A1").offset(lPolygons, 6).Value & """"
>
date: Fri, 8 Jul 2005 19:44:51 -0400   author:   John Marshall, MVP

Re: Adding a shape on a drawing to a stencil   
That wasn't what I was looking for, but you got me on the right track...

I finally noticed that the Drop method for a document allows you to drop a 
shape into the stencil and returns the Master, which is exactly what I 
needed.  Then I do a SaveAs on the document with an extension ending with 
..vss and it works... Thanks for the lead :)

    Set masterObj = vD.Drop(sCurShape, 0, 0)
    masterObj.Name = sCurShape.Name
    vD.SaveAs "VA_COs.vss"


"John Marshall, MVP" wrote:

> I do not have much time to respond tonight, but the code should look 
> something like
> Dim docObj As Visio.Document
> 
> Dim mastersObj As Visio.Masters
> 
> Dim masterObj As Visio.Master
> 
> Set docObj = Documents.Add("")
> Set mastersObj = docObj.Masters
> 
> Set masterObj = mastersObj.Add
> 
> masterObj.Name = "test"
> 
> 
> 
> --->You need to add your shape to the mastersObj collection.
> 
> FullFileName = "C:\My Documents\Visio\test1\temp1.vss"
> docObj.SaveAs FullFileName
> 
> docObj.Close
> 
> A key thing to remember is that there is only one Visio file format, the 
> extension vss, vsd, vst tells Visio how to open the file.  So you can create 
> a stencil by saving a drawing as a vsd then renaming it to a vss.
> 
> John...    Visio MVP
> 
> Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
> Need VBA examples?   http://www.mvps.org/visio/VBA.htm
> Common Visio Questions http://www.mvps.org/visio/common_questions.htm
> "adb"  wrote in message 
> news:A5EADB04-C311-48BE-A1A9-6AA316C040B1@microsoft.com...
> >I now have a bunch of shapes on a drawing that were generated through VBA. 
> >I
> > now want them to become Masters in a new stencil.  I cannot figure out how 
> > to
> > programatically add the existing shapes to a stencil though.  Is it even
> > possible or do I need to go about it another way?  Every thing I find
> > involves doing it by doing:
> > set master1 = mydocument.masters.add, but this method doesn't seem 
> > possible
> > the way I am doing it because my shapes are created after grouping 
> > multiple
> > shapes together and adding properties to them.  Code snippit below, using
> > VISIO 2000.  I need to somehow add sCurShape to a new stencil
> >
> >    vA.ActiveWindow.Group
> >    Set sCurShape = vA.ActiveWindow.Selection(1)
> >
> >    sCurShape.Name = xlws.Range("A1").offset(lPolygons, 6).Value & "_"
> >
> >    sCurShape.AddNamedRow Visio.visSectionProp, "Name", 0
> >    sCurShape.Cells("Prop.Name.Label").Formula = """Name"""
> >    sCurShape.Cells("Prop.Name.Format").Formula = """@"""
> >    sCurShape.Cells("Prop.Name.Type").Formula = 0
> >    sCurShape.Cells("Prop.Name.Value").Formula = """" &
> > xlws.Range("A1").offset(lPolygons, 6).Value & """"
> > 
> 
> 
>
date: Mon, 11 Jul 2005 05:09:02 -0700   author:   adb

Re: Adding a shape on a drawing to a stencil   
The same file format was a convoluted way of saying what you found out.

When you drop a shape on a page it adds it to the local stencil that is 
contained within the document. When you open a Visio file as a stencil, what 
you see is what is contained in the local stencil. When you open it as a 
drawing you will see the drawing and a local stencil.

One thing to note is that a "pure" stencil does not have anything on it's 
drawing page, so you may want to delete the shapes you dropped from the 
drawing page. The copies on the local stencil will remain.

John...    Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples?   http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
"adb"  wrote in message 
news:7C4C650B-EA7F-4460-90D5-0EC57E66D4B8@microsoft.com...
> That wasn't what I was looking for, but you got me on the right track...
>
> I finally noticed that the Drop method for a document allows you to drop a
> shape into the stencil and returns the Master, which is exactly what I
> needed.  Then I do a SaveAs on the document with an extension ending with
> .vss and it works... Thanks for the lead :)
>
>    Set masterObj = vD.Drop(sCurShape, 0, 0)
>    masterObj.Name = sCurShape.Name
>    vD.SaveAs "VA_COs.vss"
>
>
> "John Marshall, MVP" wrote:
>
>> I do not have much time to respond tonight, but the code should look
>> something like
>> Dim docObj As Visio.Document
>>
>> Dim mastersObj As Visio.Masters
>>
>> Dim masterObj As Visio.Master
>>
>> Set docObj = Documents.Add("")
>> Set mastersObj = docObj.Masters
>>
>> Set masterObj = mastersObj.Add
>>
>> masterObj.Name = "test"
>>
>>
>>
>> --->You need to add your shape to the mastersObj collection.
>>
>> FullFileName = "C:\My Documents\Visio\test1\temp1.vss"
>> docObj.SaveAs FullFileName
>>
>> docObj.Close
>>
>> A key thing to remember is that there is only one Visio file format, the
>> extension vss, vsd, vst tells Visio how to open the file.  So you can 
>> create
>> a stencil by saving a drawing as a vsd then renaming it to a vss.
>>
>> John...    Visio MVP
>>
>> Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
>> Need VBA examples?   http://www.mvps.org/visio/VBA.htm
>> Common Visio Questions http://www.mvps.org/visio/common_questions.htm
>> "adb"  wrote in message
>> news:A5EADB04-C311-48BE-A1A9-6AA316C040B1@microsoft.com...
>> >I now have a bunch of shapes on a drawing that were generated through 
>> >VBA.
>> >I
>> > now want them to become Masters in a new stencil.  I cannot figure out 
>> > how
>> > to
>> > programatically add the existing shapes to a stencil though.  Is it 
>> > even
>> > possible or do I need to go about it another way?  Every thing I find
>> > involves doing it by doing:
>> > set master1 = mydocument.masters.add, but this method doesn't seem
>> > possible
>> > the way I am doing it because my shapes are created after grouping
>> > multiple
>> > shapes together and adding properties to them.  Code snippit below, 
>> > using
>> > VISIO 2000.  I need to somehow add sCurShape to a new stencil
>> >
>> >    vA.ActiveWindow.Group
>> >    Set sCurShape = vA.ActiveWindow.Selection(1)
>> >
>> >    sCurShape.Name = xlws.Range("A1").offset(lPolygons, 6).Value & "_"
>> >
>> >    sCurShape.AddNamedRow Visio.visSectionProp, "Name", 0
>> >    sCurShape.Cells("Prop.Name.Label").Formula = """Name"""
>> >    sCurShape.Cells("Prop.Name.Format").Formula = """@"""
>> >    sCurShape.Cells("Prop.Name.Type").Formula = 0
>> >    sCurShape.Cells("Prop.Name.Value").Formula = """" &
>> > xlws.Range("A1").offset(lPolygons, 6).Value & """"
>> >
>>
>>
>>
date: Mon, 11 Jul 2005 11:34:40 -0400   author:   John Marshall, MVP

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us