PDA

Click to See Complete Forum and Search --> : Using Word in VB - Invalid page fault in OLE32.DLL


enevoljm
Nov 22nd, 1999, 03:25 AM
I am using Microsoft Word as my reporting tool for a VB app. Everything works fine on my development PC, but on a couple of other PCs VB crashes with 'invalid page fault in OLE32.DLL'. We've installed the msot recent version of DCOM95 and that didn't make a difference.

The code is as follows:

Set m_wrdReport = New Word.Application
m_wrdReport.Documents.Open (App.Path & "\Templates\Par.doc")

.
.
.

With m_wrdReport.Selection.Find
.ClearFormatting
.Text = sHeader
.Execute Forward:=True
End With

Clipboard.Clear
Clipboard.SetText (sData)
m_wrdReport.Selection.Paste
Clipboard.Clear

When the program tries to execute the ClearFormatting method, VB crashes. What this code is doing is looking for a specific word in the document (located in the sHeader variable) and replacing it with another value (in the sData variable).

MartinLiss
Nov 22nd, 1999, 10:49 PM
Since VB is crashing this is a long-shot, but have you manually gone to Word, recored a macro that does what you are trying to do in your program, and then compared the code in that macro to the code in your program to see if you are missing anything?

------------------
Marty

enevoljm
Nov 22nd, 1999, 10:52 PM
Yes I recorded a macro in Word to do a search and replace. It didn't give me any new insights. The key question to me is why does it work on the development PC and not on other PCs? What's missing on the other PCs that I have on my dev PC? On of the PCs that it crashes on is another development PC that has VB. This is how I know it crashes on the ClearFormatting method - by tracing through the code on the dev PC that it crashes on.

JHausmann
Nov 23rd, 1999, 12:59 AM
The problem can be almost anything *if* the pc's are not mirror images of one another. I use automation to read/write to Excel and one problem I encountered was that the test machines, the user machine and my machine all had different SP levels of Excel. Oddly enough, the test machines version fell between mine and the user and they were the only ones experiencing the problem.

Step 1 ensure that all machines are running the exact same version of Word.
Step 2 examine the .dll's used by the different machines (feel free to curse Microsoft while doing so)