Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / March 2007

Tip: Looking for answers? Try searching our database.

Word does not come to the front automatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ramudu - 28 Mar 2007 16:15 GMT
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
ramudu - 28 Mar 2007 16:19 GMT
Just one correction above -

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

- Sri

> Hi,
>
[quoted text clipped - 28 lines]
>
> - Sri
Peter Jamieson - 28 Mar 2007 17:58 GMT
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
> Hi,
>
[quoted text clipped - 28 lines]
>
> - Sri
ramudu - 28 Mar 2007 19:39 GMT
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

On Mar 28, 12:58 pm, "Peter Jamieson"
<p...@KillmapSpjjnet.demon.co.uk> wrote:
> I'm not sure I can help in this case, but
>  a. how are you invoking Word?
[quoted text clipped - 33 lines]
>
> > - Sri
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.