Illegal operation error while exporting data to MS Word.
Posted on 2003-11-06
In my VB program, it contains a function to export a ADODB recordset to MS Word. (MS Access DB)
It work fine on other computers. However, in one computer (Win2000), an error message appears...
"This program has performed an illegal operation and will be shut down."
It said is the problem with kernel32.dll.
The source codes are...
Public wrdApp As Word.Application
Public wrdDoc As Word.Document
Public wrdSelection As Word.Selection
public functiob ExportWord()
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
' Add a new document
Set wrdDoc = wrdApp.Documents.Add
Set wrdSelection = wrdApp.Selection
wrdSelection.PageSetup.LeftMargin = 50
wrdSelection.PageSetup.RightMargin = 50
. . . ..
wrdDoc.Saved = True
' Release References
Set wrdSelection = Nothing
Set wrdDoc = Nothing
Set wrdApp = Nothing