Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-21-2013, 11:15 AM
ofair ofair is offline Macro to DT Picker, but default to Weekdays Windows XP Macro to DT Picker, but default to Weekdays Office 2010 32bit
Novice
Macro to DT Picker, but default to Weekdays
 
Join Date: May 2013
Posts: 1
ofair is on a distinguished road
Default Macro to DT Picker, but default to Weekdays


Hi,

I want to create a Macro that links two Content Controls. When the user selects the date in the first box, it appears again in the second box. If the user selects a Sunday or Saturday, The second box defaults to the Monday.

Right now I have:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim CCtrl As ContentControl, LngDt As Long
If ContentControl.Title <> "StartDate" Then Exit Sub
LngDt = CDate(ContentControl.Range.Text)
For Each CCtrl In ActiveDocument.ContentControls
  If CCtrl.Title = "EndDate" Then
  With CCtrl
    .LockContents = False
    .Range.Text = Format(LngDt, "DD MM YYYY")
    .LockContents = False
  End With
  
  ElseIf CDate(ContentControl.Range.Text) Mod 7 = 1 Then
  With CCtrl
    .LockContents = False
    .Range.Text = Format(Int(CDate(ContentControl.Range.Text) / 7) * 7 + 2, "DD MM YYYY")
    .LockContents = False
  End With
  
  End If
Next
End Sub
But the defaulting ends up happening to "StartDate" when I want it to happen to "EndDate". Any suggestions?
Reply With Quote
  #2  
Old 05-21-2013, 03:07 PM
macropod's Avatar
macropod macropod is offline Macro to DT Picker, but default to Weekdays Windows 7 32bit Macro to DT Picker, but default to Weekdays Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Cross-posted at: http://social.technet.microsoft.com/...-20e93b72313e/
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to DT Picker, but default to Weekdays Date Picker Andy2011 Word VBA 4 11-24-2012 10:07 PM
Macro to DT Picker, but default to Weekdays Color picker eye dropper ??? stoneygeorge PowerPoint 7 08-28-2012 12:32 AM
Macro to DT Picker, but default to Weekdays word 2003 date picker nashville Word 16 04-06-2012 04:12 AM
Date picker trintukaz Excel 0 12-30-2011 12:42 AM
Calculations using values from date picker controls Inkarnate Word 0 06-09-2010 07:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:51 AM.


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