Solved

Word 97 and Visual Basic 4.0 16 bit

Posted on 2000-03-23
6
199 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
Comment Utility
I forgot.

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

Jeff
0
 
LVL 1

Expert Comment

by:pclement
Comment Utility

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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:georgeman
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks,
I re-installed everything, but only installed VB4.0 16 bit. It seems to work ok.

Jeff
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now