Open Word from Access give error

S

SFKC

Hi,

I follow this newsgroup yesterday and found a link (function) to open word
from Access. When I bind this function to a button, I reveive error at the
declaration line (Private mobjWordApp As Word.Application ). Could somebody
advice.

SF


'****** Code Start ********
'This code was originally written by Dev Ashish
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Dev Ashish
'
Private mobjWordApp As Word.Application <====== Error in this line

Private Sub Command1_Click()
Const conTEMPLATE_NAME = "\Templates\merge.dot"

Set mobjWordApp = New Word.Application
With mobjWordApp
.Visible = True
.WindowState = wdWindowStateMaximize
.Documents.Add Template:=(.Options.DefaultFilePath( _
wdUserTemplatesPath) _
& conTEMPLATE_NAME)
End With
End Sub
'****** Code End ********
 
M

M.L. Sco Scofield

Gee SF, the *exact* error message would have been some excellent information
to have.

Based on the line you pointed out and not knowing the exact error message,
my best guess is that you didn't set a reference to Microsoft Word.

In the VBA editor, go to Tools / References and scroll way down to the
Microsoft Word xx Object Library and check that.

If that doesn't fix the problem, post back with the exact error message that
you are getting.

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 

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