Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a Word template from Access

Status
Not open for further replies.

BillyL

IS-IT--Management
Joined
Jul 18, 2000
Messages
91
Location
US
I want to open a Word template that is setup to merge with a query in Access. I created an application button to open Word, but how do I open a new document based on a template using the Access application button?
 
Hi

I am not sure of the answer to your question.

It will probably be easier to run this process from word using the MailMerge functionality.

Probably not what you wanted to hear.

Regards

Sadcow
 
I am not sure that this will help but I will post some code that I have to do this. You may still have a bit of work to do to get it working right.

Here is the call:

If (mdl_MSWord.OpenMicrosoftWord(subfrm("fsubCorrespondenceViewLetter").Form!OLE_Document, obj_MSWord)) Then

here is the function:

Function OpenMicrosoftWord(objfrm_MSWord As BoundObjectFrame _
, obj_MSWord As Object _
) As Boolean
'This function opens Microsoft Word. This function requires a bound object frame that
' contains microsoft word documents or templates.

On Error GoTo Errorhandler
Dim obj_MSWordApplication As Word.Application

Dim bol_status As Boolean

bol_status = True

objfrm_MSWord.verb = acOLEVerbOpen 'Tells MS Access to open the application
objfrm_MSWord.Action = acOLEActivate ' Activates the application

Set obj_MSWordApplication = objfrm_MSWord.Object.Application
Set obj_MSWord = obj_MSWordApplication.ActiveDocument

OpenMicrosoftWord = bol_status
Exit Function

Errorhandler:
OpenMicrosoftWord = False
Select Case Err
Dim varRetVal As Variant
Case Else: varRetVal = ErrorMsg("OpenMicrosoftWord", Err, Error)
End Select
End Function

I hope it helps at least point you in the right direction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top