Re: VBA macro in Word global template by Doug
Doug
Thu Jun 19 12:32:49 PDT 2008
Sorry, the code should have been:
Dim myrange As Range
Set myrange = Selection.Sections(1).Headers(wdHeaderFooterFirstPage).Range
myrange.InlineShapes.AddPicture filename:=strLogoPath, _
LinkToFile:=False, SaveWithDocument:=True, Range:=myrange
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"v_fas" <vfas@discussions.microsoft.com> wrote in message
news:0B1E3B79-155F-4ECC-9E02-B3413E1BF6AA@microsoft.com...
> Actually, it placed the logo into the second page header. It should be
> inserted into the first page header.
>
> *******************
> Public Function InsertLogo(strLogoPath As String) As Boolean
>
> On Error GoTo ErrHandler
>
> With ActiveDocument 'msadded
> .PageSetup.DifferentFirstPageHeaderFooter = True 'msadded
> Dim myrange As Range
> Set myrange = Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range
> myrange.InlineShapes.AddPicture FileName:=strLogoPath, _
> LinkToFile:=False, SaveWithDocument:=True, Range:=myrange
> InsertLogo = True
> Exit Function
> ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
> End With 'msadded
>
> Exit Function
>
> '############################
> ErrHandler:
> '############################
>
> InsertLogo = False
>
> FunctionName = "Main.InsertLogo"
> strmsg = ""
>
> Call Main.ErrorHandler(FunctionName, strmsg)
>
> End Function
> *****************8
>
> "Doug Robbins - Word MVP" wrote:
>
>> Use
>>
>> Dim myrange As Range
>>
>> Set myrange = Selection.Sections(1).Headers(wdHeaderFooterPrimary).Range
>> myrange.InlineShapes.AddPicture filename:=strLogoPath, _
>> LinkToFile:=False, SaveWithDocument:=True, Range:=myrange
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "v_fas" <vfas@discussions.microsoft.com> wrote in message
>> news:CC4F4080-EB1C-4E69-B0F1-286A7DC9B12B@microsoft.com...
>> >I ahve a Word 2003 main.dot global template. I need to bea able to
>> >insert
>> >a
>> > logo inside the header on the firs tpage; but to leave alone and not
>> > consider
>> > a focus the second page header. below is the code.
>> >
>> > ************
>> > Public Function InsertLogo(strLogoPath As String) As Boolean
>> >
>> > On Error GoTo ErrHandler
>> >
>> > ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
>> > With ActiveDocument 'msadded
>> > .PageSetup.DifferentFirstPageHeaderFooter = True 'msadded
>> > With .Sections(1).Headers(wdHeaderFooterFirstPage) 'msadded
>> > ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
>> > Selection.InlineShapes.AddPicture FileName:=strLogoPath,
>> > LinkToFile:=False, _
>> > SaveWithDocument:=True
>> >
>> > InsertLogo = True
>> > Exit Function
>> > ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
>> > End With 'msadded
>> >
>> > End With
>> >
>> > '############################
>> > ErrHandler:
>> > '############################
>> >
>> > InsertLogo = False
>> >
>> > FunctionName = "Main.InsertLogo"
>> > strmsg = ""
>> >
>> > Call Main.ErrorHandler(FunctionName, strmsg)
>> >
>> > End Function
>>
>>
>>