Solved

Illegal operation error while exporting data to MS Word.

Posted on 2003-11-06
12
180 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

825 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