Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Microsoft Word 8.0 object model Question #1

Posted on 1999-07-02
Medium Priority
Last Modified: 2010-05-02
On a form, I have a command button with the following code inserted on the Click event:

Private Sub Command1_Click()

Dim wordapp As New Word.Application

wordapp.Visible = True

Set wordapp = Nothing

End Sub

When you click the button for the first time, it opens up Microsoft Word. However, if you do not close Word and click the button again, you get a VB runtime error (Automation error). What you really want to happen is another instance of Word to open up.

It seems the problem is to do with trying to start another Winword.exe process, but I can't work out how to solve it.

That's the question, I hope someone can help.


S Williams.
Question by:TheNugget
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
  • 4
  • 2
LVL 10

Expert Comment

ID: 1521476
Spooky, I tried the same but had no problem.
Are you working on an operating system or are you using Windows 95?
LVL 13

Accepted Solution

Mirkwood earned 400 total points
ID: 1521477
problems on:
              Word 95        Word 98       Word 2000
- Win95          No              No             No
- WinNT          No              No             No
- Win98          No              No             No
- Win2000        No              No             No

LVL 10

Expert Comment

ID: 1521478
What about this for a test:

Option Explicit
Dim objWApp As Word.Application

Private Sub cmdExit_Click()

If objWApp Is Nothing Then
    'no need to do anything
    Exit Sub
End If

Dim objX As Word.Document

For Each objX In objWApp.Documents
    objX.Close False
    'False = close it without prompting for changes

objWApp.Quit False
'False = If anything's still open you won't be prompted for save.

Set objWApp = Nothing

End Sub

Private Sub cmdNew_Click()

If objWApp Is Nothing Then
    Set objWApp = New Word.Application
End If

'Add a new document
If objWApp.Visible = False Then
    objWApp.Visible = True
End If


End Sub

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.

LVL 10

Expert Comment

ID: 1521479
Mirkwood - surely TheNugget is not imagining the problem?
LVL 13

Expert Comment

ID: 1521480
Yep he is..
LVL 10

Expert Comment

ID: 1521481

Author Comment

ID: 1521482
I've got a feeling it's some problem with the way Microsoft Office is set up on my system.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

670 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