Solved

Illegal operation error while exporting data to MS Word.

Posted on 2003-11-06
12
188 Views
Last Modified: 2010-05-03
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.


Please help~~



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
    wrdDoc.Select
    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
end function

0
Comment
Question by:morye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
12 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9693326
Function doesn't contain error handling. Add error handling with detailed error description and run program again.
0
 

Author Comment

by:morye
ID: 9694016
I had added the error handle, but the error still exist.
0
 
LVL 5

Expert Comment

by:IThema
ID: 9694030
...or debug and specify the location this error occurs. What Word version have you got? And what Word object library is referenced? Version 8 (Office '97) or 9 (Office 2000)???

btw: always handle errors while modifying print-settings. If no printer is installed on your system or your system cannot connect to a printer (for example: laptop from the company, not attached to network anymore can't find a printer) then an error will occur when you're trying to set the printer orientation for example.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:morye
ID: 9694139
The word version is Office 2000.

I can't use error handle to handle the error.

the code is...

public functiob ExportWord()
On error goto errH


0
 

Author Comment

by:morye
ID: 9694178
srory, wrong post....


The word version is Office 2000.

I can't use error handle to handle the error.

the code is...

public functiob ExportWord()
On error goto errH
...
...
.
exit function

errH:
  msgbox err.Number & vbcrlf & err.description
end function

The error wasn't display with the message box. It seems to be is a window error.


Thank you~~~
0
 
LVL 5

Expert Comment

by:IThema
ID: 9694239
... and you say it's only one computer? Re-installing MS Office MIGHT help. My reason to believe that is because you say it's only one computer and that the error handling doesn't handle the error...

But still one more thing before you might re-install Office (word): Can you debug the application? Please state then on what line of code the error message pops up.
0
 

Author Comment

by:morye
ID: 9694355
Before I posted this question, I already re-installed the MS Office....but, it still not works...

The situation is I had install the VB to program to several computers. But, only one computer have this error appear.

According it's my client's computer,  I can't install the Visual basic to the computer. So, it's not easy to state each line.

However, I think the error is appear between these lines..

    Set wrdApp = CreateObject("Word.Application")
    wrdApp.Visible = True
   
    ' Add a new document
    Set wrdDoc = wrdApp.Documents.Add

because the MS Word is open, but haven't any new word file create.

Thank You.
0
 
LVL 5

Expert Comment

by:IThema
ID: 9694535
Maybe a strange question, but is this client's computer significantly slower than the other computers?
0
 

Author Comment

by:morye
ID: 9698233
no~
All the computers (at the before) is the same setting.
But, all computers have use for a period.
I don't know how the user use it.

He maybe install or remove some porgrams himself. It makes some setting files changed......etc.


Please help~~~
0
 
LVL 5

Accepted Solution

by:
IThema earned 200 total points
ID: 10163128
I completely forgot about this question. Sorry for that.
Rereading this question made me think of a situation I had myself a while ago. However, I don't recall that having anything to do with kerner.dll.

My problem was solved by completely uninstalling Office before re-installing it. If that doesn't help and there really is something with the kernel and if really all computers have the same windows OS, the same Service Pack and the same Office version then I'd simply recommend you to re-install the entire computer. The fact that your error handler doesn't catch any error means your application is OK to me.

I hope you already solved your problem, otherwise you could try the things I stated above.

Cheers and good luck...
0
 

Author Comment

by:morye
ID: 10250913
Thank you very much.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

719 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