?
Solved

Word 97 and Visual Basic 4.0 16 bit

Posted on 2000-03-23
6
Medium Priority
?
207 Views
Last Modified: 2013-11-25
I am using Visual Basic 4.0, 16 bit, and have Word97 installed on the same machine. I'm able to open Word and insert a metafile, while the Visual Basic program is running, without any problems.
If I try to programmatically open Word and insert the same metafile, Word crashes with an Invalid Page Fault. I only have 32M of RAM on this machine. Am I asking too much from the hardware, or is there something different about vb 4.0 16 bit code? Is there something about the OLE I need to change? I noticed that on a machine with both VB4.0 16 bit, and VB 6.0 installed, it works (running 4.0) I will attach the small code segment...

Set NewDoc = CreateObject("word.application")
NewDoc.Documents.Add
NewDoc.Visible = True

With NewDoc.selection
    .inlineshapes.addpicture filename:="C:\hpgraph.wmf", linktofile:=False, savewithdocument:=True
   
0
Comment
Question by:jscharpf
[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
  • 3
  • 2
6 Comments
 

Author Comment

by:jscharpf
ID: 2650769
I forgot.

It opens word ok, but crashes at the line that inserts the picture.

Jeff
0
 
LVL 1

Expert Comment

by:pclement
ID: 2650877

Somewhat perplexing. Are you using early or late binding on the Word object?

In other words if you are declaring NewDoc as Word.Application, try using late binding and declaring NewDoc as Object.

This is just a stab in the dark, but early binding sometimes fails between 16 and 32-bit COM objects.
0
 

Author Comment

by:jscharpf
ID: 2651116
pclement
Thanks for the response.

I declared NewDoc as Object (globaly) in the declarations section.
Was I to do this before or after declaring newdoc as word.app?

Jeff
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 1

Expert Comment

by:georgeman
ID: 2651468
jscharpf
I tested your source code on my PC and it works fine in environment: VB4 16-bit, Word 97.
I only added:
End With

I have no idea why it crashed on you PC.
Did you try use Word.Basic instead Word.Application ?

Regards
George
0
 
LVL 1

Accepted Solution

by:
pclement earned 300 total points
ID: 2651716
ischarpf:

Declare it as Object first and then use CreateObject to create the instance:

Dim NewDoc as Object

Set NewDoc = CreateObject("Word.Application")

Like I said, I'm not sure if this will work, but give it a try and see if it makes any difference.

 
0
 

Author Comment

by:jscharpf
ID: 2661939
Thanks,
I re-installed everything, but only installed VB4.0 16 bit. It seems to work ok.

Jeff
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

762 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