Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2018, 09:06 PM
Sarah123 Sarah123 is offline wdHeaderFooterFirstPage Windows 10 wdHeaderFooterFirstPage Office 2016
Novice
wdHeaderFooterFirstPage
 
Join Date: Nov 2018
Posts: 9
Sarah123 is on a distinguished road
Default wdHeaderFooterFirstPage

Hi Everyone,

I'm just having a little error with some code. I'm wanted a header & footer to insert on the first page only.

When my code is written as the following it works fine, but inserts onto all pages of the document.



Code:
  Set headerPic = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.AddPicture(SrcePath)
However when I change to the following, the code appears to run, but nothing happens & I don't receive any error notification.

Code:
  Set headerPic = ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range.InlineShapes.AddPicture(SrcePath)
Any help or advice you have would be greatly appreciated.
Reply With Quote
  #2  
Old 11-20-2018, 10:24 PM
Guessed's Avatar
Guessed Guessed is offline wdHeaderFooterFirstPage Windows 10 wdHeaderFooterFirstPage Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Is the page setup of Section 1 set to show the different first page?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 11-22-2018, 07:35 PM
Sarah123 Sarah123 is offline wdHeaderFooterFirstPage Windows 10 wdHeaderFooterFirstPage Office 2016
Novice
wdHeaderFooterFirstPage
 
Join Date: Nov 2018
Posts: 9
Sarah123 is on a distinguished road
Default

Hi @Guessed,

Whenever I do that in my code, it runs but nothing happens. If I manually change it to have a different first page, it will remove it from the first page and leave it on the rest of the document.

Something so simple is proving quite difficult for me!
Reply With Quote
  #4  
Old 11-23-2018, 02:00 AM
Guessed's Avatar
Guessed Guessed is offline wdHeaderFooterFirstPage Windows 10 wdHeaderFooterFirstPage Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Sarah

Your code is making some assumptions which might be why you don't see the result. Making a change in the first page header of Section 1 assumes that Section 1 is configured to show the first page. There may also be confusion if there is a continuous section break on the first page.

In earlier versions of Word, I have wrestled with the placement of floating shapes in headers since VBA treats them as all being in the first section. That code issue shouldn't apply because you are placing the graphic inline but it might be something to look for.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Other Forums: Access Forums

All times are GMT -7. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft