Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-03-2017, 12:37 PM
dwirony dwirony is offline Windows 7 64bit Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 48
dwirony is on a distinguished road
Default Good morning/afternoon/evening based on time


Hello again,

I've written some code to autopopulate an email from word to outlook, however I want to add one last feature that adjusts the first line based on what time it is. If it's before 12 p.m. I want it to say good morning, between 12 p.m. and 5 p.m. to say good afternoon, and after 5 p.m. to say evening... However, I'm not sure how to incorporate a date function to create those 3 scenarios... anyone have any idea?
Reply With Quote
  #2  
Old 01-03-2017, 01:01 PM
dwirony dwirony is offline Windows 7 64bit Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 48
dwirony is on a distinguished road
Default

Oops. Found a good solution. Here it is:

Code:
Select Case Time
        Case Is < TimeValue("12:00")
            msg = "Good morning"
        Case Is < TimeValue("16:00")
            msg = "Good afternoon"
        Case Else
            msg = "Good evening"
    End Select
Reply With Quote
Reply
Please reply to this thread with any new information or opinions.

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
PPT Progress Bar based on Time not the # of Slides The Dutchman PowerPoint 0 12-14-2016 09:59 AM
filtering a list based clock time DPD16 Excel 8 01-06-2016 03:29 PM
Automatically Delete Slides based on current time Pacman52 PowerPoint 2 07-16-2015 05:30 AM
Good Word-based Document Assembly Software? Grahamers Word 1 05-13-2013 04:42 PM
field value based on time of day akraw Word 3 03-26-2011 08:29 PM


All times are GMT -7. The time now is 09:45 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft