Solved

OLE Automation Access -> Word

Posted on 1998-01-04
3
613 Views
Last Modified: 2008-02-01
1. This has to work with Access 2,95,97 and Word 6,95,97 (I don't mind using different commands in the different versions, but the pinciple should remain the same.)

2. I want to
- open a document in Word from within Access via OLE-Automation
- edit the document
- display it to the user
- let him/her edit it
- save it and quit word or use word for the next document

3. I already have this code in Access 2 for Word 97:

Dim wrd As Object
Set wrd = CreateObject("word.basic")
wrd.filenew "c:\office42\winword\spz_br.dot"
wrd.insert "how easy is this? :)"
wrd.startofdocument
wrd.editfind "easy"

4. I know AccessBasic / VB so you can keep it easy.
How to continue in 3. to solve the task described in 2.

5. I only will accept complete answers, if you just have an advice please only comment. If this advice solves my problem I will give you the points anyway.

6. Thanks in advance :-)
0
Comment
Question by:BBC
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
ramrom earned 250 total points
ID: 1964269
Option Compare Database
Option Explicit
' EITHER "Dim wrd As Object" here to give it life beyond the execution time of the
' subroutine OR "Global wrd As Object" here to also make it visible outside this module
Global wrd As Object
--------------------------------------------------------------------------------------------

Sub open_word (doc)
  On Error GoTo bad_open_word
' word.basic will open the version of word that is currently registered as the
' "owner" of word.basic. The same commands will work with any version of word
  Set wrd = GetObject(, "word.basic") ' see if word is already open; if so use it
  wrd.appshow ' make word visible
  wrd.filenew doc
  wrd.insert "how easy is this? :)"
  wrd.startofdocument
  wrd.editfind "easy"
' at this point your user should be in word in the opened document
' assuming your user will eventually return to access, another call to this
' routine will open the next document in word

exit_wrd:
  Exit Sub

bad_open_word:
  If Err = 2713 Then ' word not open
    Set wrd = CreateObject("word.basic") ' open word
    Resume Next
  Else
    MsgBox "Error " & Err & Error(Err)
  End If
End Sub

0
 
LVL 1

Author Comment

by:BBC
ID: 1964270
whoops ! Where has my comment gone ? So again:
This works very well for Word 97.
But I cant find the corresponidng command (to .appshow) in Word6 and Word95. (perhaps you even know the german translation coz I have the german version).
0
 
LVL 17

Expert Comment

by:ramrom
ID: 1964271
AppShow IS a Word6 and Word95 statement. I quote from the Word 6 Word Basic Reference:

AppShow [WindowName$]

Makes visible and activates an application previously hidden with AppHide and restores the application window name to the Task List. If the application is not hidden, AppShow has no effect.

Argument      Explanation
WindowName$      A string that matches the beginning of an application window name, as it would appear in the title bar or Task List if the application were visible. If omitted, Word is assumed. For more information on WindowName$, see AppActivate.

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

806 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