Hello,

I am developing a template (Report.dot) in MS Word XP. This template
contains a macro that inserts a new page, oriented landscape. The contents of
the header and footer on this page must be rotated and re-positioned on the
right and left edge of the page (using ranges and frames) so that when the
final document is printed and assembled, all headers and footers are
consistent.

My problem is when I try to select and rotate the logos (jpeg images), I get
the following runtime error : "-2147024891 This member cannot be accessed at
this time".

The code I am using is as follows:

Dim rngHeadr As Range
Dim shpLogo As Shape

With ActiveDocument.Sections(intSectionID)
Set rngHeadr = .Headers(wdHeaderFooterPrimary).Range
End With

For Each shpLogo In rngHeadr.ShapeRange
shpLogo.Select ' <- Error occurs here
Selection.ShapeRange.IncrementRotation 90#
Next

Can anyone give me a work-around ? I will be very grateful !

--
Lars

RE: Rotating a logo in header by lf

lf
Tue Oct 23 14:12:02 PDT 2007

You cannot select anything in a header unless the selection is already in the
header. However, you do not need to select anything (and should not). Just
use the range object.

If you replace the following 2 code lines:

shpLogo.Select
Selection.ShapeRange.IncrementRotation 90#

with this line:

shpLogo.IncrementRotation 90#

your logo should be rotated without being selected.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


"Lars" wrote:

> Hello,
>
> I am developing a template (Report.dot) in MS Word XP. This template
> contains a macro that inserts a new page, oriented landscape. The contents of
> the header and footer on this page must be rotated and re-positioned on the
> right and left edge of the page (using ranges and frames) so that when the
> final document is printed and assembled, all headers and footers are
> consistent.
>
> My problem is when I try to select and rotate the logos (jpeg images), I get
> the following runtime error : "-2147024891 This member cannot be accessed at
> this time".
>
> The code I am using is as follows:
>
> Dim rngHeadr As Range
> Dim shpLogo As Shape
>
> With ActiveDocument.Sections(intSectionID)
> Set rngHeadr = .Headers(wdHeaderFooterPrimary).Range
> End With
>
> For Each shpLogo In rngHeadr.ShapeRange
> shpLogo.Select ' <- Error occurs here
> Selection.ShapeRange.IncrementRotation 90#
> Next
>
> Can anyone give me a work-around ? I will be very grateful !
>
> --
> Lars
>

RE: Rotating a logo in header by Lars

Lars
Wed Oct 24 01:37:39 PDT 2007

Hello Lene,

It works !!

Many thanks for your help. Your solution is so simple. Now that I see how it
works, I guess I was so bogged down with the different elements of ranges and
shapes that I could not see the forest, because all the trees blocked my view.

Many thanks again :)
--
Lars

"Lene Fredborg" wrote:

> You cannot select anything in a header unless the selection is already in the
> header. However, you do not need to select anything (and should not). Just
> use the range object.
>
> If you replace the following 2 code lines:
>
> shpLogo.Select
> Selection.ShapeRange.IncrementRotation 90#
>
> with this line:
>
> shpLogo.IncrementRotation 90#
>
> your logo should be rotated without being selected.
>
> --
> Regards
> Lene Fredborg
> DocTools - Denmark
> www.thedoctools.com
> Document automation - add-ins, macros and templates for Microsoft Word
>
>
> "Lars" wrote:
>
> > Hello,
> >
> > I am developing a template (Report.dot) in MS Word XP. This template
> > contains a macro that inserts a new page, oriented landscape. The contents of
> > the header and footer on this page must be rotated and re-positioned on the
> > right and left edge of the page (using ranges and frames) so that when the
> > final document is printed and assembled, all headers and footers are
> > consistent.
> >
> > My problem is when I try to select and rotate the logos (jpeg images), I get
> > the following runtime error : "-2147024891 This member cannot be accessed at
> > this time".
> >
> > The code I am using is as follows:
> >
> > Dim rngHeadr As Range
> > Dim shpLogo As Shape
> >
> > With ActiveDocument.Sections(intSectionID)
> > Set rngHeadr = .Headers(wdHeaderFooterPrimary).Range
> > End With
> >
> > For Each shpLogo In rngHeadr.ShapeRange
> > shpLogo.Select ' <- Error occurs here
> > Selection.ShapeRange.IncrementRotation 90#
> > Next
> >
> > Can anyone give me a work-around ? I will be very grateful !
> >
> > --
> > Lars
> >