PDA

View Full Version : [SOLVED] “Application.Speech.Speak”, to announce the greetings.



FrankM
07-24-2019, 05:24 AM
I currently have code to announce the date, when the workbook is opened, but would like to provide a more accurate greeting.
Here is the current code:

Application.Speech.Speak " Today is " & Date

I found this code which is closer to what I am trying to accomplish, I am having trouble finding the proper syntax.
Here is code I found:

SDateTime = WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date), False) & " " & Day(Date) & ", " & Year(Date)If Hour(Time()) <= 12 Then
greet = "Good morning... it's "
Else
greet = "Good afternoon... it's "
End If
MsgBox greet & SDateTime

The other thing, I am trying to accomplish is improving the greetings window. Current code shows "Good Morning.....it's Wednesday, July 24, 2019"
I would like to add a period at the end. So my goal is to have both the window & speech with the same greeting.

FrankM
07-24-2019, 07:31 AM
I have an update. I was able to incorporate the day, month, & year into Application.Speech.Speak.
Here is the current code:

Application.Speech.Speak " Today is " & WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date), False) & " " & Day(Date) & ", " & Year(Date)
Any ideas how to add the time of day. Meaning, Goods morning or Good afternoon?

Paul_Hossler
07-24-2019, 07:37 AM
Option Explicit
Sub test2()

Dim sGreet As String
If Hour(Time) <= 12 Then
sGreet = "Good morning... it's " & WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date), False) & " " & Day(Date) & ", " & Year(Date)
Else
sGreet = "Good afternoon... it's " & WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date), False) & " " & Day(Date) & ", " & Year(Date)
End If
Application.Speech.Speak sGreet
MsgBox sGreet & "."

End Sub

FrankM
07-24-2019, 09:55 AM
Paul. Thank you for the answer & quick response. After studying the code, i found it surprisingly simple & concise. :clap:

Paul_Hossler
07-24-2019, 11:33 AM
Paul. Thank you for the answer & quick response. After studying the code, i found it surprisingly simple & concise. :clap:


Simple is my middle name :devil2:

You can mark your thread SOLVED using the instructions in #3 of my sig

FrankM
07-24-2019, 12:09 PM
Your comment. LOL