Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word Header

Status
Not open for further replies.

crayonshinchan

Technical User
Sep 29, 2009
3
SG
MS word 2003
i wanted to print the check list
but we always need to manually key in the date on the header.
can vba help us to enter 1 week 7 days to print out same check list but the header with diff date?

Thkx
 
Can you explain in more detail?

WHAT "check list"? What has some "check list" have to do with a header?

"can vba help us to enter 1 week 7 days to print out same check list but the header with diff date?"

Probably yes, but you need to state more clearly what is going on.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
Hi
Our date are store inside the Header.
We need manually to change the date.

Does VBA allow us to key in 1 week to print out
the documents with different date?

thk
 
Yes.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
Hi crayonshinchan,

You are not being especially clear about what you're trying to do.

On the assumption that you want the user to be able to input a date into the macro then have the document printed with that date on the header then looped through and printed with the dates for the next week, you could try something like:
Code:
Sub Test()
Dim StrDate As String, i As Integer
StrDate = InputBox("What is the starting date?")
If IsDate(StrDate) Then
  StrDate = DateAdd("d", -1, StrDate)
  For i = 1 To 7
    ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text _
      = Format(DateAdd("d", 1, StrDate), "dddd, d MMMM yyyy")
    ActiveDocument.PrintOut
  Next
End If
End Sub


Cheers
[MS MVP - Word]
 
Hi

This is what i need,thank you so much for your help.
I only work as security guard,sorry for my poor technical knowledge.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top