Solved

Word 97 and Visual Basic 4.0 16 bit

Posted on 2000-03-23
6
201 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 33
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 46
VB6 ListBox Question 4 42
Where did System.Data.Objects go? 2 27
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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