Prev: how to i create a dialog box using xml schema
Next: Toggle button code to insert user response into template
From: Michaelcip on 27 May 2010 17:45 Thanks in advance. I'm using Word 2003 & I'd like to populate a cell of a table to fill in the last Sunday-DATE of that week. This is for a timesheet.doc where that date needs to be filled in for our Payroll Dept. Currently folks are having to go to a calendar & look up in order to manually populate this field. Many thanks, MC
From: Graham Mayor on 28 May 2010 01:56 If you want NEXT Sunday then you will need to change the code to Sub NextSunday() Dim sDate As Date Dim i As Long sDate = Date i = 8 - WeekDay(sDate) Selection.TypeText sDate + i End Sub You will need to run the macro from a toolbar button or keyboard shortcut see http://www.gmayor.com/installing_macro.htm -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "Michaelcip" <Michaelcip(a)discussions.microsoft.com> wrote in message news:07DA8245-1CE1-48B3-B718-492C1026E625(a)microsoft.com... > Thanks Graham, I recognize this as VBA, but don't know where/how to do > this. > I think if you give me simple instructions I can navigate through it > enough. > > Also just to clarify, what I'm after is (w/ today being the 27th) I'd like > this cell to populate w/ the date "5/30/2010" (& if it were the 25th, it > would still populate w/ "5/30/2010") > > Many thanks, MC > > "Graham Mayor" wrote: > >> Something along the lines of >> >> Dim sDate As Date >> Dim i As Long >> sDate = InputBox("Date today", , Date) >> i = WeekDay(sDate) - 1 >> Selection.TypeText sDate - i >> >> will type the date of the previous Sunday at the cursor. >> >> If you want to use today's date as the start point instead of the input >> box >> then use >> >> sDate = Date >> in place of >> sDate = InputBox("Date today", , Date) >> >> -- >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> Graham Mayor - Word MVP >> >> My web site www.gmayor.com >> Word MVP web site http://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> >> >> >> "Michaelcip" wrote: >> >> > Thanks in advance. >> > I'm using Word 2003 & I'd like to populate a cell of a table to fill in >> > the >> > last Sunday-DATE of that week. This is for a timesheet.doc where that >> > date >> > needs to be filled in for our Payroll Dept. Currently folks are having >> > to go >> > to a calendar & look up in order to manually populate this field. >> > Many >> > thanks, MC
From: Michaelcip on 28 May 2010 11:49 Will try this. Thanks to both Doug & Graham for your imput. Have a great holiday weekend! Michaelcip "Graham Mayor" wrote: > If you want NEXT Sunday then you will need to change the code to > > Sub NextSunday() > Dim sDate As Date > Dim i As Long > sDate = Date > i = 8 - WeekDay(sDate) > Selection.TypeText sDate + i > End Sub > > You will need to run the macro from a toolbar button or keyboard shortcut > see http://www.gmayor.com/installing_macro.htm > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > > "Michaelcip" <Michaelcip(a)discussions.microsoft.com> wrote in message > news:07DA8245-1CE1-48B3-B718-492C1026E625(a)microsoft.com... > > Thanks Graham, I recognize this as VBA, but don't know where/how to do > > this. > > I think if you give me simple instructions I can navigate through it > > enough. > > > > Also just to clarify, what I'm after is (w/ today being the 27th) I'd like > > this cell to populate w/ the date "5/30/2010" (& if it were the 25th, it > > would still populate w/ "5/30/2010") > > > > Many thanks, MC > > > > "Graham Mayor" wrote: > > > >> Something along the lines of > >> > >> Dim sDate As Date > >> Dim i As Long > >> sDate = InputBox("Date today", , Date) > >> i = WeekDay(sDate) - 1 > >> Selection.TypeText sDate - i > >> > >> will type the date of the previous Sunday at the cursor. > >> > >> If you want to use today's date as the start point instead of the input > >> box > >> then use > >> > >> sDate = Date > >> in place of > >> sDate = InputBox("Date today", , Date) > >> > >> -- > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > >> Graham Mayor - Word MVP > >> > >> My web site www.gmayor.com > >> Word MVP web site http://word.mvps.org > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > >> > >> > >> > >> "Michaelcip" wrote: > >> > >> > Thanks in advance. > >> > I'm using Word 2003 & I'd like to populate a cell of a table to fill in > >> > the > >> > last Sunday-DATE of that week. This is for a timesheet.doc where that > >> > date > >> > needs to be filled in for our Payroll Dept. Currently folks are having > >> > to go > >> > to a calendar & look up in order to manually populate this field. > >> > Many > >> > thanks, MC > > > . >
From: macropod on 30 May 2010 03:47 Hi Michaelcip, To see how to do this and just about everything else you might want to do with dates in Word, check out my Microsoft Word Date Calculation Tutorial, at: http://lounge.windowssecrets.com/index.php?showtopic=249902 or http://www.gmayor.com/downloads.htm#Third_party In particular, look at the item titled 'Calculate a Stepped Date'. Do read the document's introductory material. -- Cheers macropod [Microsoft MVP - Word] "Michaelcip" <Michaelcip(a)discussions.microsoft.com> wrote in message news:AB6CC016-C015-41A7-9D2B-CAA05BB1AB83(a)microsoft.com... > Thanks in advance. > I'm using Word 2003 & I'd like to populate a cell of a table to fill in the > last Sunday-DATE of that week. This is for a timesheet.doc where that date > needs to be filled in for our Payroll Dept. Currently folks are having to go > to a calendar & look up in order to manually populate this field. Many > thanks, MC
From: Michaelcip on 3 Jun 2010 12:41
Thank-you very, very much for your input "macropod" I will look @ this now. MC "macropod" wrote: > Hi Michaelcip, > > To see how to do this and just about everything else you might want to do with dates in Word, check out my Microsoft Word Date > Calculation Tutorial, at: > http://lounge.windowssecrets.com/index.php?showtopic=249902 > or > http://www.gmayor.com/downloads.htm#Third_party > In particular, look at the item titled 'Calculate a Stepped Date'. Do read the document's introductory material. > > -- > Cheers > macropod > [Microsoft MVP - Word] > > > "Michaelcip" <Michaelcip(a)discussions.microsoft.com> wrote in message news:AB6CC016-C015-41A7-9D2B-CAA05BB1AB83(a)microsoft.com... > > Thanks in advance. > > I'm using Word 2003 & I'd like to populate a cell of a table to fill in the > > last Sunday-DATE of that week. This is for a timesheet.doc where that date > > needs to be filled in for our Payroll Dept. Currently folks are having to go > > to a calendar & look up in order to manually populate this field. Many > > thanks, MC > > . > |