Data timestamp

B

breeze

Data timestamp
I need set data timestamp on my Word, Excel document which automatically appears om my document when I prepare them, with the following format: current week from the beginning of year/day/ year. How I can doing this?

Thanks
 
H

Helmut Weber

Hi Breeze,
I need set data timestamp on my Word, Excel document which automatically appears om my document when I prepare them, with the following format: current week from the beginning of year/day/ year. How I can doing this?
not too clear, what you really need.
Have a look at datediff() as a start,
MsgBox DateDiff("ww", "01/01/2004", Now, , vbFirstFullWeek)
returns 29 for the current week here with my german version.
But it is not quite simple, as the way of calculating the week
number offers 4 constants, that is 4 ways of defining "1st week":
vbUseSystem = 0
vbFirstJan1 = 1
vbFirstFourDays = 2
vbFirstFullWeek = 3
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
B

breeze

Hi Helmut,

could you be more detail, I am not very familiar with macro. First, I need this for Word.
Regards,
Breeze
 
H

Helmut Weber

Hi Breeze,
this group is about programming.
Try "public.docmanangement" or "public.newusers".
And be a bit more precise.
Where should the week number be placed?
In what formatting?
current "week from the beginning of year/day/ year"
What is "day" in your definition?
"Day/year" would be a rather strange date format.
Without any priliminary knowledge on your side
it is rather difficult to help you.
Are you able to record a macro?
 
B

breeze

Hi,

I need insert timestamp for Word docs, when I go to Insert > Date and Time >Available Formats: I find there poor common microsoft offers.
I need just the following format: 24/ 20-07-2004 where first data is current week of current year( week/ day-month-year) Its elemenrary thing, of course I tried find some ready appropriate macro, then insert this macro in Word doc. I can no write a macro myself. Unfortunately, microsoft does not give the user any convenience, but constant problems with they software..
 
H

Helmut Weber

Hi Breeze,
the following macro inserts week and date
at the position of the cursor. If you don't
know, how to put a macro to use, try to record
one, edit it [alt-F11], delete it and paste the
following code. Close the editor, and try "extras"
"macros" "execute" or something like that, as I
unfortunately got a german version. Some
people with an english version of word will
assist you further, if required, I hope.
What language version of word have you got?
Sub Mydate()
' vbUseSystem = 0
' vbFirstJan1 = 1
' vbFirstFourDays = 2
' vbFirstFullWeek = 3
Dim s As String
Selection.Collapse
s = DateDiff("ww", "01/01/2004", Now, , 0) & "/ "
s = s & Format(Now, "dd-mm-yyyy")
Selection.TypeText Text:=s
End Sub
Hope this helps.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
H

Helmut Weber

Hi Breeze,
great! Didn't expect to get so far at first!
Better place the macro in normal.dot "sub autonew", if it should
work for all new documents. And change my faulty date format to
"mm-dd-yyyy" for month, day, year. The thing with the week is,
that there are different ways of counting. In germany, more than
everything is so strictly regulated, that there is an official way
of counting weeks. I have no idea where you are and what are the
rules there. There are 4 possibilities, e.g.:
DateDiff("ww", "01/01/2004", Now, , vbFirstFullWeek)
where vbFirstFullWeek = 3 and means, the 1st week in the year
is the first complete week in the year. Which arises the question,
whether a week starts with sunday or monday. It's awful.
DateDiff("ww", "01/01/2004", Now, , vbUseSystem) '0
DateDiff("ww", "01/01/2004", Now, , bFirstJan1) '1
DateDiff("ww", "01/01/2004", Now, , vbFirstFourDays) '2
DateDiff("ww", "01/01/2004", Now, , vbFirstFullWeek) '3
Just check it out.
And forgive me for asking, where are you from, how old are you?
It makes things easier, if one has a more or less clear picture
of the person, one is talking to.
Have a nice day!
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
H

Helmut Weber

Hi Breeze,
if nothing of the offered possibilities is satisfying you,
you can still force it. Like this:
sub test1
MsgBox DateDiff("ww", "01/01/2004", Now, , vbFirstFullWeek)
end sub ' result 29 here and now
sub test2
MsgBox DateDiff("ww", "01/01/2004", Now, , vbFirstFullWeek) + 1
end sub ' result 30 here and now
Regarding specific docs, there must be a way to know them.
Difficult for a beginner, again. But you are learning very fast.
Your boss must learn, too. This is the most difficult thing,
If a doc is for an overseas customer,
the name of the doc must start with "OS"! "Like OS-microsoft-01.doc".
Then you could your macro make dependant on the first 2 letters.
If left(activedocument.name, 2) = "OS" then
' datestamp
endif
Keep on!
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 

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