Solved

Word and DAO

Posted on 2002-04-08
4
250 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
[X]
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
  • 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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

749 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