Solved

OLE Automation Access -> Word

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

896 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

13 Experts available now in Live!

Get 1:1 Help Now