Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

OLE Automation Access -> Word

Posted on 1998-01-04
3
Medium Priority
?
649 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 1000 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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 …
Suggested Courses

972 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