From: roursler on
I am making a macro for printing medication labels. I need to have an
expiration time on the label and would like it to be the current time + 6
hours. How can I structure the field to do this?
From: Doug Robbins - Word MVP on
I would put a { docvariable exptime } field in the label where you want the
time to appear and in your code use

With ActiveDocument
.Variables("exptime").Value = Format(DateAdd("h", 6, Now), "h:mm am/pm")
.Range.Fields.Update
.PrintOut
End With

You must use Ctrl+F9 to insert the field delimiters around the docvariable
field and use Alt+F9 to toggle off their display

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"roursler" <roursler(a)discussions.microsoft.com> wrote in message
news:77CA2157-36DE-4769-97BD-7B0B7D23BB4C(a)microsoft.com...
> I am making a macro for printing medication labels. I need to have an
> expiration time on the label and would like it to be the current time + 6
> hours. How can I structure the field to do this?

From: Karl E. Peterson on
Doug Robbins - Word MVP explained on 1/15/2010 :
>> would like it to be the current time + 6 hours.
>
> Format(DateAdd("h", 6, Now), "h:mm am/pm")

Not that there's anything wrong with that approach. It's probably the
most readable answer there is. Just wanted to kick in another method,
for sake of having all options out there.

Background: Date variables are really Doubles in drag. The day is
stored in the whole portion, and the time in the fractional part.

So, to add 6 hours, one need only add a quarter of a day:

Format(Now + 0.25, "h:mm am/pm")

Might be useful, for more calculation intensive operations...

--
..NET: It's About Trust!
http://vfred.mvps.org


From: Doug Robbins - Word MVP on
Thanks, Karl. Good to know.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:eNHu#cWmKHA.2680(a)TK2MSFTNGP04.phx.gbl...
> Doug Robbins - Word MVP explained on 1/15/2010 :
>>> would like it to be the current time + 6 hours.
>>
>> Format(DateAdd("h", 6, Now), "h:mm am/pm")
>
> Not that there's anything wrong with that approach. It's probably the
> most readable answer there is. Just wanted to kick in another method, for
> sake of having all options out there.
>
> Background: Date variables are really Doubles in drag. The day is stored
> in the whole portion, and the time in the fractional part.
>
> So, to add 6 hours, one need only add a quarter of a day:
>
> Format(Now + 0.25, "h:mm am/pm")
>
> Might be useful, for more calculation intensive operations...
>
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
>
From: redtwotwo on
Hi. I am trying something similar as this but I would like to create a
sheet of labels which has the date + 15 days. How would you suggest
implementing this? There are many labels per page, do I have to create
many different variables and allow the vba to set each one or is there
an easier way?

I have used vba in excel but this is my first venture for word. I
would be grateful for help in this area.

Thanks
Heather

On Jan 20, 2:44 am, "Doug Robbins - Word MVP"
<d...(a)REMOVECAPSmvps.org> wrote:
> Thanks, Karl.  Good to know.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>
> "Karl E. Peterson" <k...(a)exmvps.org> wrote in messagenews:eNHu#cWmKHA.2680(a)TK2MSFTNGP04.phx.gbl...
>
> > Doug Robbins - Word MVP explained on 1/15/2010 :
> >>> would like it to be the current time + 6 hours.
>
> >>    Format(DateAdd("h", 6, Now), "h:mm am/pm")
>
> > Not that there's anything wrong with that approach.  It's probably the
> > most readable answer there is.  Just wanted to kick in another method, for
> > sake of having all options out there.
>
> > Background: Date variables are really Doubles in drag.  The day is stored
> > in the whole portion, and the time in the fractional part.
>
> > So, to add 6 hours, one need only add a quarter of a day:
>
> >    Format(Now + 0.25, "h:mm am/pm")
>
> > Might be useful, for more calculation intensive operations...
>
> > --
> > .NET: It's About Trust!
> >http://vfred.mvps.org

 |  Next  |  Last
Pages: 1 2
Prev: Remove/hide General folder
Next: Borderless form