question about developing with shapesheet

D

David

i'm trying to change a cell's formula of a line master by code and it
doesn't work.

the following code doesn't work:

Set mastObj = stnObj.Masters("Line")
Set shpObj = mastObj.PageSheet
Set celObj = shpObj.Cells("LockWidth")
celObj.Formula = "1"

but when i tried to change the formula of the line as a shape after i
droped it to the frame it did work.
the following code did work:
Set mastObj = stnObj.Masters("Line")
Set shpObj = pagObj.Drop(mastObj, 4.25, 5.5)
Set celObj = shpObj.Cells("LockWidth")
celObj.Formula = "1"

what am i doing wrong???
btw the first code compiled. i just didn't see it changed any
formula.
 
J

JuneTheSecond \)cotton.ocn.ne.jp>

Hi David,

Are you going to edit a shape on stencil?
If so, please confirm that the stencil is
open in edit omode.
You might close the stencil and open again
with openex method in read-write mode.
.....and
Set shpObj = mastObj.PageSheet
might be better written as
Set shpObj = mastObj.Shapes(1).

--
Best Regards.

JuneTheSecond
Now the Visual calculation is more visual.
http://www.geocities.jp/visualcalculation/english/index.html
 
J

John... Visio MVP

David said:
i'm trying to change a cell's formula of a line master by code and it
doesn't work.

the following code doesn't work:

Set mastObj = stnObj.Masters("Line")
Set shpObj = mastObj.PageSheet
Set celObj = shpObj.Cells("LockWidth")
celObj.Formula = "1"

but when i tried to change the formula of the line as a shape after i
droped it to the frame it did work.
the following code did work:
Set mastObj = stnObj.Masters("Line")
Set shpObj = pagObj.Drop(mastObj, 4.25, 5.5)
Set celObj = shpObj.Cells("LockWidth")
celObj.Formula = "1"

what am i doing wrong???
btw the first code compiled. i just didn't see it changed any
formula.


What are you trying to do.

The first set of code lines gets access to a master in the stencil defined
by stnObj, it then sets the LockWidth for the masters`page. You probably
need to change the shape associated with the master.

So are you trying to drop a master and then Lock the width of the shape or
are you trying to change the Lockwidth of the master

Remember, a Master is a container for a shape, so you need to find the shape
within the master.

John... Visio MVP
 
D

David

Hi David,

Are you going to edit a shape on stencil?
If so, please confirm that the stencil is
open in edit omode.
You might close the stencil and open again
with openex method in read-write mode.
....and
Set shpObj = mastObj.PageSheet
might be better written as
Set shpObj = mastObj.Shapes(1).

--
Best Regards.

JuneTheSecond
Now the Visual calculation is more visual.http://www.geocities.jp/visualcalculation/english/index.html

i tried to use OpenEx with the flag visOpenRW but then i get an error
that the file is already open for read only and cannot be opened for
modifications.
 
D

David

What are you trying to do.

The first set of code lines gets access to a master in the stencil defined
by stnObj, it then sets the LockWidth for the masters`page. You probably
need to change the shape associated with the master.

So are you trying to drop a master and then Lock the width of the shape or
are you trying to change the Lockwidth of the master

Remember, a Master is a container for a shape, so you need to find the shape
within the master.

John... Visio MVP- Hide quoted text -

- Show quoted text -

hi John
i'm trying to change the LockWidth of the master. i'm not trying to
drop the master to the frame and then to change its LockWidth. i'm
actually not intending to drop any shape to the frame. i'm just
creating the stencil for the user.
i'm studying from the book "developing in visio" and it explains that
if i want to update the shapesheet of a master i should get its
PageSheet property which returns a Shape object and then i can use the
Cells property to change a cell formula. but for some reason it
doesn't work...

btw the LockWidth was just an example. what i'm really trying to do
is to create the master PolyLine (two or more lines connected to each
other). for now when the user moves PolyLine i created to the frame,
a window apears and asks the user how many lines he wants in the
PolyLine. if he writes x lines i should add x lines to the Geometry1
section in the PolyLine shapesheet and i have to do it in code because
the number of lines in the section depends on the user's answer.
anyway, i haven't succeeded to chage any master in the stencil. only
the shape after i dropped it to the frame which is not what i wanted.
 
J

John... Visio MVP

hi John
i'm trying to change the LockWidth of the master. i'm not trying to
drop the master to the frame and then to change its LockWidth. i'm
actually not intending to drop any shape to the frame. i'm just
creating the stencil for the user.
i'm studying from the book "developing in visio" and it explains that
if i want to update the shapesheet of a master i should get its
PageSheet property which returns a Shape object and then i can use the
Cells property to change a cell formula. but for some reason it
doesn't work...

btw the LockWidth was just an example. what i'm really trying to do
is to create the master PolyLine (two or more lines connected to each
other). for now when the user moves PolyLine i created to the frame,
a window apears and asks the user how many lines he wants in the
PolyLine. if he writes x lines i should add x lines to the Geometry1
section in the PolyLine shapesheet and i have to do it in code because
the number of lines in the section depends on the user's answer.
anyway, i haven't succeeded to chage any master in the stencil. only
the shape after i dropped it to the frame which is not what i wanted.


I'm a bit tied up now, but I can give you a fuller answer in a few days.

The book 'Developing in Visio' does not strike a bell, but if you can post a
page referenece, I would like to check it out. You should not have to be
playing with the PageSheet property. You should be playing with the Masters
collection of the stencil document and for each Master, you should be
accessing it's Shapes collection.

Playing with Polylines should peek Chris Roth's (aka Visio Guy) curiosity.
He has an example of how to work with a shapes master on his blog.
http://www.visguy.com/2008/02/25/edit-visio-masters-programmaticallythe-right-way/

John...
 
D

David

hi John
i'm trying to change the LockWidth of the master.  i'm not trying to
drop the master to the frame and then to change its LockWidth.  i'm
actually not intending to drop any shape to the frame.  i'm just
creating the stencil for the user.
i'm studying from the book "developing in visio" and it explains that
if i want to update the shapesheet of a master i should get its
PageSheet property which returns a Shape object and then i can use the
Cells property to change a cell formula.  but for some reason it
doesn't work...

btw the LockWidth was just an example.  what i'm really trying to do
is to create the master PolyLine (two or more lines connected to each
other).  for now when the user moves PolyLine i created to the frame,
a window apears and asks the user how many lines he wants in the
PolyLine.  if he writes x lines i should add x lines to the Geometry1
section in the PolyLine shapesheet and i have to do it in code because
the number of lines in the section depends on the user's answer.
anyway, i haven't succeeded to chage any master in the stencil.  only
the shape after i dropped it to the frame which is not what i wanted.

I'm a bit tied up now, but I can give you a fuller answer in a few days.

The book 'Developing in Visio' does not strike a bell, but if you can post a
page referenece, I would like to check it out. You should not have to be
playing with the PageSheet property. You should be playing with the Masters
collection of the stencil document and for each Master, you should be
accessing it's Shapes collection.

Playing with Polylines should peek Chris Roth's (aka Visio Guy) curiosity..
He has an example of how to work with a shapes master on his blog.http://www.visguy.com/2008/02/25/edit-visio-masters-programmaticallyt...

John...

what i told you is written in chapter 17 ("Automating Formulas") at
the first sub-chapter ("Working with Formulas in Cells"). at the top
of this sub-chapter (i don't have the exact page because i have the
book as a file in the computer and not the actual book) it explains in
three bullets how to change the cells of a shape. at the second
bullet it explains what to do in case we want to work with formulas of
a Page or a Master. here is the exact quotation of the second bullet:

"To work with formulas of a Page or Master object, use the PageSheet
property of the object, which returns a Shape object. You can then use
the Cells or CellSRC property of that Shape object to work with its
formulas. "

now back to what you said. you said not to use the PageSheet property
but the Master's shapes collection. but which shape of the shapes
collection should i use??? i guess that the shapes collection
represent the instances of the Master on the frame. but the frame is
empty. all i have is the stencil and i want to change directly the
shapesheet of the master. so i really don't understand what i should
to with the shapes collections. can you give me a code example?
 
J

JuneTheSecond \)cotton.ocn.ne.jp>

David,

Here is my test code.
LockWidthTest.vss is a simple stencil
that has a master "Line" already opend
in edit mode.

Option Explicit

Sub test()
Dim stnObj As Visio.Document
Dim mastObj As Visio.Master
Dim shpObj As Visio.Shape
Dim celObj As Visio.Cell

Set stnObj = Application.Documents("LockWidthTest.vss")
If stnObj.ReadOnly = False Then
Set mastObj = stnObj.Masters("Line")
Set shpObj = mastObj.Shapes(1)
Set celObj = shpObj.Cells("LockWidth")
celObj.Formula = "1"
stnObj.Save
Else
MsgBox "File is read only!" & vbCr & _
"Open file in edit mode."
End If
End Sub


--
Best Regards.

JuneTheSecond
Now the Visual calculation is more visual.
http://www.geocities.jp/visualcalculation/english/index.html
 
D

David

David,

Here is my test code.
LockWidthTest.vss is a simple stencil
that has a master "Line" already opend
in edit mode.

Option Explicit

Sub test()
    Dim stnObj As Visio.Document
    Dim mastObj As Visio.Master
    Dim shpObj As Visio.Shape
    Dim celObj As Visio.Cell

    Set stnObj = Application.Documents("LockWidthTest.vss")
    If stnObj.ReadOnly = False Then
        Set mastObj = stnObj.Masters("Line")
        Set shpObj = mastObj.Shapes(1)
        Set celObj = shpObj.Cells("LockWidth")
        celObj.Formula = "1"
        stnObj.Save
    Else
        MsgBox "File is read only!" & vbCr & _
          "Open file in edit mode."
    End If
End Sub

--
Best Regards.

JuneTheSecond
Now the Visual calculation is more visual.http://www.geocities.jp/visualcalculation/english/index.html

thanks for you code. but i noticed something weird. it indeed changed
the LockWidth of the Line master to 1. but when i draged the line to
the frame and checked the shapesheet of the line on the frame the
LockWidth was zero. i could change the width of the line after i
dropped it from the stencil to the frame. how come??? the width is
supposed to be locked isn't it?
and another question. why mastObj.Shapes(1)? i don't know what the
collection Shapes represent in the master Line so i don't know why
Shapes(1) is a reference to the master itself. can you tell me
briefly?

thanks
david
 
J

JuneTheSecond \)cotton.ocn.ne.jp>

David,

The Visio drawing has drawing stencil in each.
If you have dropped a master, the master remains
in the drawing stencil. It is the mechanizm unique to
Visio that helps to save resoouces.
If the master on the drawing stencil has the cell of
Lockwidth =0, then any master of same name might
be Lockwidth =0 neveretheless of the value in the
regular stencil.
To prevent it, you might need to change the value of
LockWidth of the master in the drawing stencil, or
delete the master in the drawing stencil, or change
the name of new master.
You might found these informations in the Visio
SDK documents.

You might easy to confirm my code in the completely
new drawing.

--
Best Regards.

JuneTheSecond
Now the Visual calculation is more visual.
http://www.geocities.jp/visualcalculation/english/index.html
 
D

David

David,

The Visio drawing has drawing stencil in each.
If you have dropped a master, the master remains
in the drawing stencil. It is the mechanizm unique to
Visio that helps to save resoouces.
If the master on the drawing stencil has the cell of
Lockwidth =0, then any master of same name might
be Lockwidth =0 neveretheless of the value in the
regular stencil.
To prevent it, you might need to change the value of
LockWidth of the master in the drawing stencil, or
delete the master in the drawing stencil, or change
the name of new master.
You might found these informations in the Visio
SDK documents.

You might easy to confirm my code in the completely
new drawing.

--
Best Regards.

JuneTheSecond
Now the Visual calculation is more visual.http://www.geocities.jp/visualcalculation/english/index.html

i thought that in visio every shape on the frame that was created by
dropping a master has exactly the same properties the master has (plus
some more properties like position in the frame etc...).
if you change the LockWidth in the Line master from the shapesheet
directly in visio and not by code then when you drop the master into
the frame its width is locked. how can i make exatcly the same thing
by code?
i didn't understand why you said that i might change the master's name
or delete it from the drawing stencil. i just want to change its
properties and by that to change all the shapes the user drops on the
frame from this master. can you tell me what should i change in your
code to make it work?

thanks in advance
David
 
D

David

i thought that in visio every shape on the frame that was created by
dropping a master has exactly the same properties the master has (plus
some more properties like position in the frame etc...).
if you change the LockWidth in the Line master from the shapesheet
directly in visio and not by code then when you drop the master into
the frame its width is locked.  how can i make exatcly the same thing
by code?
i didn't understand why you said that i might change the master's name
or delete it from the drawing stencil.  i just want to change its
properties and by that to change all the shapes the user drops on the
frame from this master.  can you tell me what should i change in your
code to make it work?

thanks in advance
David- Hide quoted text -

- Show quoted text -

oh, sorry, now i understand what you said. i read the link given
earlier and it explained that. i forgot about the link before that
sorry.

thanks everybody for the help.
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top