Formatting MS Word Footers with VBA -- from Excel

MacroEcon1337

Board Regular
Joined
Mar 16, 2017
Messages
64
I have an excel macro – (not handy at the moment, but can fetch tomorrow AM if needed) – which creates a fresh Word document, and transfers/pastes into it about 50 pages of text/image content from Excel.

But the footers are killing me. What I am looking for is this:



--------------------------------------footer begin below--------------------------------------
<LOGO IMAGE: left justified> <PAGE #: right justified>
--------------------------------------- end footer----------------------------------------------



Can anyone think of a simple code which would create a fresh word document with footers that look like the above?

Notes:


1. I think a 2x1 TABLE may need to be injected into the Footer - otherwise, the Logo Image and Page # both want to JUSTIFY the same direction.

2. Page # needs to be dynamic - like a field code -- that way they update if new pages are inserted into the word document AFTER it has been created.

I worked all afternoon on this, and could not solve. Any suggestions or code greatly appreciated,


MC
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
If you're doing this often, which seems likely, you should create a Word template with the page layout, including headers & footers, you require. You'd the reference that template when using the .Documents.Add method, obviating the need to create the page layout etc. in code.

As for the justification, you don't need a table, simply use an ordinary paragraph with a right-aligned tab-stop at the right margin and insert a tab character between the logo and the PAGE field.
 
Last edited:
Upvote 0
The problem is there are sections (spaced at random intervals, depending on the data), for which there are no footers at all.

I realize we could begin with a template (with footers), and then programmatically delete the footers in those sections. But my preference is to build from scratch.

Is this possible, or am i wandering down an alleyway of terrible complexity?

MC
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top