Solved

Word and DAO

Posted on 2002-04-08
4
254 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…

717 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