Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Illegal operation error while exporting data to MS Word.

Posted on 2003-11-06
12
Medium Priority
?
190 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

610 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