?
Solved

Word and DAO

Posted on 2002-04-08
4
Medium Priority
?
269 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
ID: 6926472
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
ID: 6931362
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 400 total points
ID: 6931644
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
ID: 6937206
Thanks that is logical
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

807 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