connecting Word97 <----> Access97 
Author Message
 connecting Word97 <----> Access97

Hello NG,
I'm a VBA beginner and I would like to realize the following steps:

Word97 dokument is opend, a keyword marked
How can I connect to Access97.
Add an new dataset.
Copy the marked text into an element?
read out annother element and write to the actual curser positon in Word.

Any help??

Thanks for all!!!

Bruno



Fri, 24 May 2002 03:00:00 GMT  
 connecting Word97 <----> Access97
Well that is certainly ambitious for your first vba undertaking...

Anyway... you need to add a reference (Tools | References in the
VBE window) to either the DAO or ADO type libraries in order to
get access to access.

When you say add a new dataset I assume you mean a new record to
a table, right?

To get the keyword, which I assume is selected (is this what you mean
by marked?), you can use the selection object in word.

The code would look something like this...
Public Sub AddRecord()

Dim dbCur As DAO.Database
Dim rstCur As DAO.Recordset

    ' open the database
    Set dbCur = OpenDatabase("C:\MyDocuments\MyDatabase.mdb")
    If Not (dbCur Is Nothing) Then

        ' open the table
        Set rstCur = dbCur.OpenRecordset("MyTable", dbOpenDynaset)
        If Not (rstCur Is Nothing) Then

            With rstCur

                ' add a new record
                .AddNew

                ' set the Name field to the selected text
                .Fields("Name") = Selection.Text

                ' update the recordset
                .Update

                ' close the recordset
                .Close

            End With ' rstCur

        End If

        ' close the database
        dbCur.Close

    End If

End Sub

--
Will Rickards [MVP Word]
Software Engineer
http://members.home.net/wrickard

Please post ALL replies/requests to the newsgroup for the benefit of the newsgroup.
disclaimer: Use of any information/code provided is at your own risk.
My e-mail address has been modified to prevent ****.

Quote:

> Hello NG,
> I'm a VBA beginner and I would like to realize the following steps:

> Word97 dokument is opend, a keyword marked
> How can I connect to Access97.
> Add an new dataset.
> Copy the marked text into an element?
> read out annother element and write to the actual curser positon in Word.

> Any help??

> Thanks for all!!!

> Bruno



Sat, 25 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. <<<<<<<<ComboBox>>>>>>>>>>>>

2. HELP >>>>>>WIN API <<<<<<<<<<

3. Help wanted on connecting Word97<->VB

4. help me out please!!!!<<<<<<<<<<<<<<<<<<<<<<<thanks>>>>>>>>>>>>>>>>>>>>>>>>

5. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

6. <<<<HELP- OLE container Control>>>>>>>>>

7. VB5<->RDO2<->ODBC<->ORACLE Procedure Problem

8. <<<Cneck Box>>>

9. <<<Gif Files>>>

10. <<<CD ROM>>>

11. <<<Win32Api.TXT>>>

12. <<<NetWork Drv>>>

 

 
Powered by phpBB® Forum Software