Using AutoNew() and bookmarks in Header footers

J

jpottsx1

My problem is that I want to put in the footer of my page the text
"Report for the week:" and have word insert the result using this week
as the starting point. So I have the calculation working but I cannot
get it to work in the footers. I've tried using a different bookmark
name and putting the bookmark in and running the template but now use.

Any direction on the Header footer issue would be great

Jeff


====================================================
Sub AutoNew()
On Error Resume Next
Selection.GoTo What:=wdGoToBookmark, Name:="wDate"
Selection.InsertBefore Format(WeekStart() - 7, "d/m/yy")
Selection.InsertAfter " to "
Selection.InsertAfter Format(WeekStart(), "d/m/yy")
End Sub

Function WeekStart() As Date
Dim wday As Byte
wday = Weekday(Date)
Select Case wday
Case 1
WeekStart = Date
Case 2
WeekStart = Date - 1
Case 3
WeekStart = Date - 2
Case 4
WeekStart = Date - 3
Case 5
WeekStart = Date - 4
Case 6
WeekStart = Date - 5
Case 7
WeekStart = Date - 6
End Select
End Function
 
C

Charles Kenyon

Bookmarks don't work well in headers/footers. By definition bookmarks are
unique, appearing on only one page. A header/footer is on multiple pages (at
least potentially). But see
http://www.jojo-zawawi.com/code-samples-pages/code-samples.htm.

Here is an article about manipulating text in headers/footers that may help
you get started.
http://word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top