Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-26-2016, 05:12 PM
oxicottin oxicottin is offline Add VBA to a button in Word Windows 7 32bit Add VBA to a button in Word Office 2007
Novice
Add VBA to a button in Word
 
Join Date: Dec 2012
Posts: 5
oxicottin is on a distinguished road
Default Add VBA to a button in Word

Hello, I have a 07 word document that I have a date in a table that I want to change to the next following Sunday when I click the button Named (PrintWeek). So lets use next week for instance, I enter 10/2/16 into this tables cell and click the button and it prints the document and changes the date to 10/9/16. How can I do this?



The cell is F:1

Thanks,
Reply With Quote
  #2  
Old 09-26-2016, 07:10 PM
macropod's Avatar
macropod macropod is offline Add VBA to a button in Word Windows 7 64bit Add VBA to a button in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If it's always the next following Sunday from whatever 'today' is, you don't need a macro. 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://windowssecrets.com/forums/sho...ation-Tutorial
or:
http://www.gmayor.com/downloads.htm#Third_party
In particular, look at the item titled Calculate a Stepped Date - for which the field is already configured to calculate 'next' Sunday. Do read the document's introductory material.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-26-2016, 09:35 PM
oxicottin oxicottin is offline Add VBA to a button in Word Windows 7 32bit Add VBA to a button in Word Office 2007
Novice
Add VBA to a button in Word
 
Join Date: Dec 2012
Posts: 5
oxicottin is on a distinguished road
Default

I'm on a work PC so I cant register to look at the .zip nor can I download any third party add-ons. I'm looking for some VBA that if I entered Sundays date (9/25/16) in cell F:1 and clicked the print button Named (PrintWeek), it would print the page and automatically change that date to the following Sunday which is 10/2/16 and I can print it again and it would change the date to the next Sunday and so on.

Something like:

Private Sub PrintWeek_Click()
'ActiveDocument.Range("F:1") Something Here to change date
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
End Sub

Thanks,
Reply With Quote
  #4  
Old 09-27-2016, 01:52 PM
macropod's Avatar
macropod macropod is offline Add VBA to a button in Word Windows 7 64bit Add VBA to a button in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The download contains a Word document, not a third party add-on and you can download it without registering from the second link.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-27-2016, 04:24 PM
oxicottin oxicottin is offline Add VBA to a button in Word Windows 7 32bit Add VBA to a button in Word Office 2007
Novice
Add VBA to a button in Word
 
Join Date: Dec 2012
Posts: 5
oxicottin is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The download contains a Word document, not a third party add-on and you can download it without registering from the second link.
In the word documents im sure its the DatCal.zip im needing but not sure what to incorporate into the document to accomplish what im after
Reply With Quote
  #6  
Old 09-27-2016, 04:35 PM
macropod's Avatar
macropod macropod is offline Add VBA to a button in Word Windows 7 64bit Add VBA to a button in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Post #2 tells you which field to use. The Introduction, also referred to in Post #2, tells you how...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 09-27-2016, 09:49 PM
oxicottin oxicottin is offline Add VBA to a button in Word Windows 7 32bit Add VBA to a button in Word Office 2007
Novice
Add VBA to a button in Word
 
Join Date: Dec 2012
Posts: 5
oxicottin is on a distinguished road
Default

macropod, I understand your trying to get me to do this on my own but for peat sakes I'm lost this is nothing like excel or access. Im just going to hang up the towel I have been searching for days and word just isn't the thing to be adding buttons and VBA I guess. I just was trying to make it easier on myself printing wise. Thanks....

Quote:
Calculate a Stepped Date

The following field calculates a predetermined weekly date (in this case, [next] Sunday).
Saturday, 12 December 2009
Note: To change the day of the week on which the calculated result is based, change the 6 in the statement {SET Weekday 6} to suit, using:
(0 = Mon, 1 = Tues, 2 = Wed, 3 = Thurs, 4 = Fri, 5 = Sat, 6 = Sun)
Reply With Quote
  #8  
Old 09-27-2016, 10:02 PM
macropod's Avatar
macropod macropod is offline Add VBA to a button in Word Windows 7 64bit Add VBA to a button in Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Did you read the Introduction? If you had, and if you toggled Word's field shading on as it suggests, you'd have known by now that the 'Saturday, 12 December 2009' date in your post is a field that you can simply copy & paste from the tutorial into your document. Unless you need to adjust the field code for internationalization issues (as also discussed in the Introduction), all you need do is update the field. Indeed, if you have Word configured to 'update fields before printing', you don't even need to do that!
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add VBA to a button in Word Automatize word button. Eduardo Care Word 1 08-13-2015 06:01 PM
Calculation Button in Word tables Barry Bolton Word Tables 3 02-14-2014 06:01 PM
Add VBA to a button in Word Timestamp Button Word Victora Word VBA 1 12-29-2012 08:47 AM
Add VBA to a button in Word Clickable button in word ndjustin20 Word VBA 1 02-08-2012 02:50 PM
MS Word form - email button floydwood Word VBA 0 05-10-2009 04:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft