Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-11-2022, 09:45 AM
Makingwork Makingwork is offline Help creating a word macro Windows 10 Help creating a word macro Office 2021
Novice
Help creating a word macro
 
Join Date: Jul 2022
Posts: 4
Makingwork is on a distinguished road
Default Help creating a word macro

Hi everyone,

I am using a drop down content control box with 3 values (A, B, C).
Then I have a Date Control Control Box.
Then I have a blank space that says "Review on ____(date)"


I want to fill in the blank.

Would someone be able to help me write a script that says something like:
If Down Down Box = A, then take the "date" + 3 years, If = B then date +2 years, and if C then date = 3 years.
otherwise do nothing?

How do I go about doing this? I do not know how to code, and I'm hoping someone can help.
Is there an easier way to do it?

Thank you so much in advance!
Reply With Quote
  #2  
Old 07-11-2022, 11:18 AM
Makingwork Makingwork is offline Help creating a word macro Windows 10 Help creating a word macro Office 2021
Novice
Help creating a word macro
 
Join Date: Jul 2022
Posts: 4
Makingwork is on a distinguished road
Default

I figured out I can use an If Word Field statement referencing the DropDown content box, however I don't know how to change the date to add 3 years in the If statement

{If {REF Dropbox} = "A" Date+3years nextIFstatement}

Does anyone know how to change the Date+3 years?
Reply With Quote
  #3  
Old 07-11-2022, 04:42 PM
macropod's Avatar
macropod macropod is offline Help creating a word macro Windows 10 Help creating a word macro Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,370
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

Using fields with content controls won't give you an automatic update. See attached. Pressing Alt-F11 will reveal the VBA code used to drive the process.
Attached Files
File Type: docm DateDemo.docm (37.4 KB, 12 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 07-12-2022, 08:44 AM
Makingwork Makingwork is offline Help creating a word macro Windows 10 Help creating a word macro Office 2021
Novice
Help creating a word macro
 
Join Date: Jul 2022
Posts: 4
Makingwork is on a distinguished road
Default

Thank you so much Macropod!! <3

SOLVED!!

Last edited by Makingwork; 07-12-2022 at 10:45 AM.
Reply With Quote
  #5  
Old 07-13-2022, 07:07 AM
Makingwork Makingwork is offline Help creating a word macro Windows 10 Help creating a word macro Office 2021
Novice
Help creating a word macro
 
Join Date: Jul 2022
Posts: 4
Makingwork is on a distinguished road
Default

I have one more question. Let's say I have 2 more boxes that I need the Date to copy to.

Is it possible to have the Date copied to multiple boxes?
If I name them all "BoxesDate" only 1 updates.

Sub UpdateBoxes(j As Long, StrDt As String)
With ActiveDocument.SelectContentControlsByTitle("Boxes Date")(1)
.LockContents = False
If j = 0 Or StrDt = "" Then
.Range.Text = ""
Else
.Range.Text = ActiveDocument.SelectContentControlsByTitle("Date" )(1).Range.Text)
End If
.LockContents = True
End With
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help creating a word macro need help creating a Word macro selecting all and changing font, size, and color thanks marna Word VBA 4 12-18-2018 07:20 PM
Help creating a word macro Creating a macro from a non-saved Word doc that duplicates the current open document and saves it mike0215 Word VBA 3 11-17-2017 01:40 PM
Macro for creating word docs from existing template ferocious12 Word VBA 5 02-04-2017 09:57 PM
help creating macro in word cc.caroline15 Word VBA 10 02-23-2015 04:53 PM
Help creating a word macro help creating macro tingker Word VBA 4 01-08-2015 08:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:18 PM.


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