Results 1 to 5 of 5

Thread: Automate Responding to Prompt in Word 2003

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Automate Responding to Prompt in Word 2003

    I'm writing a simple macro that opens a Word 2003 document which is a label merge doc.

    1.When the document opens, Word prompts to say that Data from my Database will be placed in the document and do I want to continue. At this point I want to write into the macro to automatically respond "Yes". This is the option that is selected by default.

    2. Word then prompts to select the text separator from Tab, Comma or Other. Comma is the default selection, and it is the one I want. At this point I want to write into the macro to automatically respond "OK", which is the default selection.

    Everything else - the opening as read only, toggling the view, and saving as a new file I have been able to successfully manage.


  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Automate Responding to Prompt in Word 2003

    Welcome to the Forums.

    You can temporarily turn off the DisplayAlerts which will force Word to accept the defaults on these
    messages. Since your selections will be thedefaults you will be good to go.

    In the Document_Open procedure place this code there.

    VB Code:
    1. Private Sub Document_Open()
    2.     Dim iDA As Integer
    3.     iDA = Application.DisplayAlerts
    4.     Application.DisplayAlerts = wdAlertsNone
    5.     'Do your stuff
    6.     '...
    7.     '...
    8.     '...
    9.     Application.DisplayAlerts = iDA
    10. End Sub
    Or if you are sutomating Word from VB it will basically be the same.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Automate Responding to Prompt in Word 2003

    It looks like when I disable the alerts they get answered in the negative because then the merge commands are disabled. How do I answer the prompts/alerts in the positive? Do I have to find a way to tell the macro which prompt/alert is being displayed or what variables are being used in order to answer it? If so, I'm assuming since these are standard Word alerts there should be standard naming conventions for them. Where would I find this out?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Automate Responding to Prompt in Word 2003

    Doesnt it state in the first messagebox that a select statement is going to be run? The default is No.
    So this is why its not running.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Automate Responding to Prompt in Word 2003

    When I throw in the code to turn off the alerts I do not get anything about a select statement going to be run. What I do get is: Run-Time error '5852' Requested object is not available in regard to:
    ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
    I included that line because I don't want the user to see the merge codes or have anything to do but look at the data.
    I see what you're saying about the first prompt with the alerts on being about running the SQL command, but I need that to say yes. So I guess turning off the alerts won't work. So can you point me in the right direction for answering alerts?

Posting Permissions

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



Click Here to Expand Forum to Full Width