Solved

Auto answer a word dialog box from VB

Posted on 1997-06-08
2
220 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

15 Experts available now in Live!

Get 1:1 Help Now