Solved

Word and DAO

Posted on 2002-04-08
4
244 Views
Last Modified: 2010-05-02
Hi experts

   I have a problem trying to create a new document object for word processing, there is one object called document in DAO 2.5/3.5 Library and i receive the error "The use of NEW clause is invalid"

  How can i solve this?

 thanks
0
Comment
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:peterwest
Comment Utility
As far as i'm aware you don't use DAO for creating word documents - this is for creating links to databases such as MS Access.

To create a new document through code you need to include a reference to the Microsoft Word Object Library - the precise version you'll use depends on what version of Office/Word you have.   On mine it's version 9 (Office 2000).

You can then create the document by going:

Dim objWordApp As New Word.Application
Dim objNewDocument As Document

Set objNewDocument = objWordApp.Documents.Add

You can then manipulate the document using the objNewDocument object that has been defined.

Hope this helps.

Pete
0
 
LVL 12

Author Comment

by:Alfredo Luis Torres Serrano
Comment Utility
I know i have a reference to word 8 library

 The problem is that in the word 8 library the object document have the same name that a object document in DAO library and i need to use both.

 The problem still been that there is a conflict (I Think) with the document object in DAO libary with the document object (same name) in word 8 library.

Thanks

0
 
LVL 2

Accepted Solution

by:
peterwest earned 100 total points
Comment Utility
You should be able to resolve this by simply prefixing the object type with the library name.

For example,

Dim myDAODocument As DAO.Document creates DAO Document
Dim myWordDocument As Word.Document creates Word Document.

Hope this helps.

Pete
0
 
LVL 12

Author Comment

by:Alfredo Luis Torres Serrano
Comment Utility
Thanks that is logical
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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 lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

10 Experts available now in Live!

Get 1:1 Help Now