|
-
Mar 28th, 2005, 04:17 PM
#1
Thread Starter
Member
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.
-
Mar 28th, 2005, 04:24 PM
#2
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:
Private Sub Document_Open()
Dim iDA As Integer
iDA = Application.DisplayAlerts
Application.DisplayAlerts = wdAlertsNone
'Do your stuff
'...
'...
'...
Application.DisplayAlerts = iDA
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 29th, 2005, 04:32 PM
#3
Thread Starter
Member
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?
-
Mar 29th, 2005, 05:46 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Apr 18th, 2005, 11:49 AM
#5
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|