MSword OLE Object

C

ccrites

I'm a new user of OLE objects in Access 2000. Thus, I need some help.
What I'm trying to do is open MS Word and paste a "message" out of a
text box into a temporary document. This is a fairly easy problem, but
my help has been subpar as of yet. Any help would be appreciated.
Thanks in Advance...

-Casey
 
P

Penguin

I've used this code before. Edit the code to suit your needs.

'*************Code Start*******************
Public Function LinkToDoc(strName As String, strAddress As String,
strCSZ As String)
On Error GoTo LinkToDoc_Err
Dim WordApp As Word.Application
Dim strDate As String

Set WordApp = CreateObject("Word.Application")

WordApp.Documents.Add

strDate = Format(Date, "Long Date")

With WordApp.Selection
.TypeParagraph
.TypeText Text:=strDate
.TypeParagraph
.TypeParagraph
.TypeParagraph
.TypeText Text:=strName
.TypeParagraph
.TypeText Text:=strAddress
.TypeParagraph
.TypeText Text:=strCSZ
.TypeParagraph
.TypeParagraph
.TypeParagraph
.MoveEnd
End With

WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
Set WordApp = Nothing

LinkToDoc_Exit:
Exit Function

LinkToDoc_Err:
MsgBox Err.Description, , "Error #" & Err
Resume LinkToDoc_Exit
End Function
'**************************End Code*******************

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top