> When running with Breakpoints, and stepping through the code, it works as
> intended. WHen running without breaks, it screws up royally. Is there some
> other way to refer to that shape? I have tried the following:
That is *such* an annoying problem (I've run into it - or a similar
issue - myself in other contexts - program runs fine in the debugger,
but try to compile it for your client in Release mode and suddenly it
stops working). I opened a dialogue with Microsoft about it, but never
got a definitive answer on the matter.
> Set PastedShape = ActiveDocument.Pages(1).Master.Shapes.Paste
>
> PastedShape.Top = SoAndSo (also did not work, but forget error message)
I don't have access to the Publisher 2002 object model at the moment,
but IIRC it behaved the same in this regard as 2003 and 2007 do - the
.Paste method returns a ShapeRange rather than a Shape. That's why you
can't set the .Top property with your "With" block - .Top for a
ShapeRange is read-only. And I'd wager that the error you're getting
when you Set PastedShape is either the same error or a Type Mismatch.
Try:
Dim PastedRange As ShapeRange
Set PastedRange = ActiveDocument.Pages(1).Master.Shapes.Paste
PastedRange(1).Top = SoAndSo

Signature
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org
Cory - 07 May 2007 18:51 GMT
Outstanding!!@! I will have to go try that.
Previously I have had to do the .paste then something like
With ActiveDocument.Pages(1).Shapes(ActiveDocument.Pages(1).Shapes.Count)
.Top = X
.Left = y
.Name = z
End With
.Count will give the current count of shapes which should equal the index of
the newly pasted shape to refer to. <Sigh>
> That is *such* an annoying problem (I've run into it - or a similar
> issue - myself in other contexts - program runs fine in the debugger,
[quoted text clipped - 14 lines]
> Set PastedRange = ActiveDocument.Pages(1).Master.Shapes.Paste
> PastedRange(1).Top = SoAndSo
It is return "Object or With block defined variable not set." But I set the
object variable in the line immediately before the with block. Is there a
way to access the shape range after pausing the execution with a breakpoint?
I tried using the immeditate window to try and access it and get more
information (like if it was actually there) and I could not seem to.
Any thoughts?
Cory
> I am using VBA code to paste a copied shape to the Master page and then
> following on to manipulate the shape (.Top, .Left, etc.). When I refer to
[quoted text clipped - 18 lines]
>
> Cory
Ed Bennett - 08 May 2007 22:59 GMT
> It is return "Object or With block defined variable not set." But I set the
> object variable in the line immediately before the with block. Is there a
> way to access the shape range after pausing the execution with a breakpoint?
> I tried using the immeditate window to try and access it and get more
> information (like if it was actually there) and I could not seem to.
Immediately after pasting, the "Selection" object would return the
freshly-pasted ShapeRange.

Signature
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org
Cory - 10 May 2007 13:24 GMT
Alrighty. Will try that. Thanks again.
Cory
> > It is return "Object or With block defined variable not set." But I set the
> > object variable in the line immediately before the with block. Is there a
[quoted text clipped - 4 lines]
> Immediately after pasting, the "Selection" object would return the
> freshly-pasted ShapeRange.