Word does not come to the front automatically

R

ramudu

Hi,

This is not exactly a mail merge issue but happens when I do the same
so I thought I'd first put my issue here. Our software used to
implement mail merge using a DDE connection between Excel and Word.
Because of problems with Excel (specifically, inability to handle
large amounts of data and Unicode characters) we switched to using an
OleDb connection.

The problem with the OleDb connection is that Word does not
automatically popup and come in front of all the other screens like it
used to with DDE. This (the mail merge) is an important feature of our
software and our clients get queasy (?) :p when Word doesn't
automatically show up.

I did try to use the ShowWindowAsync, ShowWindow, SetForegroundWindow
methods to try and bring the Word window to the front but this doesn't
seem to help. Here's a snippet of my code below using ShowWindowAsync:

Dim pInstance As Process = _
GetRunningInstance("WINWORD")
If Not pInstance Is Nothing Then
Dim handle As IntPtr = pInstance.Handle
If Not IntPtr.Zero.Equals(handle) Then
Win32Helper.ShowWindowAsync(handle, 2)
Win32Helper.ShowWindowAsync(handle, 9)
End If
End If


Help! Thanks! :)

- Sri
 
R

ramudu

Just one correction above -

Its not the problem of Excel handling large data but that of DDE.
Thanks!

- Sri
 
P

Peter Jamieson

I'm not sure I can help in this case, but
a. how are you invoking Word?
b. are you invoking Word Application.Activate at any point?
c. are you setting Word Application.Visible = True at any point?

Peter Jamieson
 
R

ramudu

Word is invoked by the following code

m_doc = m_wrd.Documents.Open(strDoc)

where m_wrd is a reference to Word.ApplicationClass and strDoc is the
word document.

After the data binding is done to the spreadsheet for which the code
is

m_doc.MailMerge.OpenDataSource( _
Name:=m_strDsName, _
Connection:="", _
SQLStatement:="SELECT * FROM `Sheet1$`")

I activate and set the visible property to true

m_doc.Activate()
m_wrd.Visible = True

Let me know if you need anything else.

- Sri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top