kurt
Tue Aug 02 03:23:03 CDT 2005
Bonjour Jean-Guy,
Merci pour votre aide!
Can you suggest a book or two for learning VBA in Word?
Merci mille fois.
Kurt
--
kurt
"Jean-Guy Marcil" wrote:
> kurt was telling us:
> kurt nous racontait que :
>
> > I'm writing a macro that uses the following code, but at this point I
> > get an error, and my macro does not allow going into the header.
> >
> > It works perfectly on a PC at my home, but not on the PC at my office.
> >
> > The error I get is: Object variable or WithBlock variable not set
> > (Run time error 91)
> >
> > Any ideas?
> >
> > If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
> > ActiveWindow.Panes(2).Close
> > End If
> > If ActiveWindow.ActivePane.View.Type = wdNormalView Or
> > ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then
> > ActiveWindow.ActivePane.View.Type = wdPrintView
> > End If
> > ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
> > Selection.MoveDown Unit:=wdLine, Count:=2
> > Selection.PasteAndFormat (wdPasteDefault)
> >
> > ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
>
> Looks like you are using the macro recorder...
>
> This is fine to get an idea, but you should refine it by hand, see
>
> for more on this.
>
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm
>
> Meanwhile, your macro could be simplified like this:
> '_______________________________________
> With Selection.Sections(1).Headers(wdHeaderFooterPrimary) _
> .Range.Paragraphs(3).Range
>
> .PasteAndFormat wdPasteDefault
>
> End With
> '_______________________________________
>
> No Selection object and no need to "physically" go into the header.
>
> You have to make sure the current header has at least three paragraphs and
> you may want to change "wdHeaderFooterPrimary" to match your type of header.
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org
>
>
>
>