Solved

OLE Automation Access -> Word

Posted on 1998-01-04
3
599 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Send email from MS Access macro 7 31
Dcount unique 6 21
Autocomplete textbox in MS Access 2016 4 19
Error in SQL Query 36 33
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now