Consulting

Results 1 to 6 of 6

Thread: “Application.Speech.Speak”, to announce the greetings.

  1. #1
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location

    Question “Application.Speech.Speak”, to announce the greetings.

    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.

  2. #2
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location
    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?

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    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
    
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location
    Paul. Thank you for the answer & quick response. After studying the code, i found it surprisingly simple & concise.

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Quote Originally Posted by FrankM View Post
    Paul. Thank you for the answer & quick response. After studying the code, i found it surprisingly simple & concise.

    Simple is my middle name

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

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    VBAX Regular
    Joined
    Jul 2018
    Posts
    12
    Location
    Your comment. LOL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •