Solved

Auto answer a word dialog box from VB

Posted on 1997-06-08
2
218 Views
Last Modified: 2008-03-17
I'm only a beginner at the VB game as I've only just had a three day course but thought that I'd dive in at the deep(ish) end - but I'm stuck.

I currently writing a system whereby I receive data from an AS/400 and produce a 'standard' letter made up of various paragraphs (held as individual Word documents) with variable inserted as into the text.  The choice of paragraph is dependant upon the AS/400 data.

I've got VB opening up Word, then loading a base (empty) document with the mail merge set up.  I then insert the appropriate paragraph texts.  All this works fine until I come to print.  I send off the .mailmerge command to Word which seems to work fine except that Word then opens up a  Dialog box requesting the number of copies etc.  

What I am unable to do is automatically reply an OK to this.  I've tried using SendKeys, I've tried just to send a carriage return but to no avail.

I need to auto reply as this system is to sit on a machine all days processing letter requests and shouldn't require user intervention.

Can anyone out there help ??

Thanks in advance
Guy
0
Comment
Question by:Willow060797
2 Comments
 
LVL 7

Expert Comment

by:tward
ID: 1426984
Through OLE Word shouldn't prompt for anything.  Maybe post some code that you are using to do this...  If Sendkeys didn't work with an return maybe OK isn't the default button on the MessageBox being displayed, Try maybe sending something like an ALT-O or whatever...
0
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 50 total points
ID: 1426985
Assuming that you are using OLE to open your document and do your stuff, the command that you are looking for is FilePrint.

Something like this:

  Dim objWord as Object

  Set objWord = CreateObject("WordBasic")
  objWord.FileOpen ("MyFile.DOC")
  (do your stuff here)
  objWord.FilePrint
  objWord.FileSaveAs ("MyNewDoc.doc")
  Set objWord = Nothing


Hope this helps

Chris
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now