Re: How do I write a Visio macro operating on a selection?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Once again, thank you.
Maybe you could now tell me how to get the position of a shape (rectangle,
etc.)
What I want to do is the following:

Assume I have two, say, rectangles, both filled; call them A and B. A is
partially hidden by B.
I want to
* create a copy of A
* change the copy's line pattern to "9" ("fine dahsed")
* change the copy's line weight to "0.25mm" (A has "0.35mm")
* remove the copy's fill, i.e. set the pattern to "00"
* move the copy to front
* center the copy over A

The result of all this would be that the part of A hidden by B is shown
dashed.

How do I do arithmetics on line weights, positions, etc? I.e. assume e.g.
that I want to re-scale a shape's line weight by 0.5. I.e. to 0.25mm if it
was 0.5mm from the beginning, to 0.175mm if it was 0.35mm from the beginning.
How do I do that?

Best regards

Staffan Cronstrom

"John Goldsmith" wrote:

Hello Staffan,

You can get hold of the selected shapes as a property of the ActiveWindow
object. Once you have that it's just a case of running through them and
making the changes you're after:

Public Sub ChangeLineFormat()
Dim shp As Shape
Dim sel As Selection
Dim i As Integer

'Set the initial selection
Set sel = ActiveWindow.Selection

'Run through the items in the selection
For i = 1 To sel.Count
Set shp = sel(i)
With shp
.CellsU("LineWeight").FormulaU = "0.35 mm"
.CellsU("LinePattern").FormulaU = "9"
End With
Next i
End Sub

If you're interested in more information on looping code then you might find
this useful:

http://visualsignals.typepad.co.uk/vislog/2007/11/looping-through.html

Also, have you tried the macro recorder? If you want more on this have a
look at this post:

http://msmvps.com/blogs/visio/archive/2006/03/03/85364.aspx

Best regards

John


John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk

"Staffan Cronstrom" <StaffanCronstrom@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:C53D82E3-8931-439B-801A-9463C8F56163@xxxxxxxxxxxxxxxx
I want to write (create) a macro in VISIO that operates on selected
objects.
What I mean is the following:
I want to create a macro that e.g.
* sets the line weight to 0.35mm
* sets the line pattern "fine dashed", pattern n:o 9 in Format/Line
on a shape, or some shapes, I select. I.e.,
* first I would select the shape or shapes
* then I would call the macro
I want all the selected shapes to, after I've done this, have taken on the
line weight of 0.35mm and the line pattern n:o 9.



.



Relevant Pages

  • Re: Help end the testing tedium please
    ... Dim strFilter As String ... the consolidate button uses this macro (which may be a nightmare to ... With Selection ...
    (microsoft.public.excel.programming)
  • Re: Moving to next field with F11 in protected document
    ... macro is invoked with a keyboard hotkey and looks at the characters to ... a file with the name of the selection and inserts one space and then ... Dim rgeField As Range ... Dim lngStart As Long ...
    (microsoft.public.word.vba.beginners)
  • Re: My custom control has issues
    ... Ultimately I have written a new control using pieces of zoompicbox as a skeleton and it's working pretty well, but there are some problems. ... This control is called PixelViewer and that's its purpose: to view an image and let you zoom in and see the pixels as pixels, not a smoothed image. ... Since GDI+ doesn't allow for XOR drawing, I've resorted to using GDI to drawing my rubber-band selection. ... That part works fine, but when I draw the final selection rectangle I get a black box, not inverted colors. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Including Subfolders for use within Word 2003 Macro
    ... Then selected from the Tools bar, Macro, in WORD 2003 and OFFICE 2003 ... folders to look in and then I selected a folder with documents I ... the three references you list should be sufficient. ... >>where we make the actual selection. ...
    (microsoft.public.word.docmanagement)
  • My custom control has issues
    ... I posted a thread a couple of weeks back titled "I need to zoom a bitmap ... Ultimately I have written a new control using ... to using GDI to drawing my rubber-band selection. ... when I draw the final selection rectangle I get a black box, ...
    (microsoft.public.dotnet.framework.drawing)