Solved

OLE Automation Access -> Word

Posted on 1998-01-04
3
622 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

821 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