Command Button

F

Froto

Here's my problem.

I am following Cheryl Fischer's 1/23/2004 post regarding
sending data from access form to word template I created.
I have the following code behind the onclick of my
command button.

Dim objWord As Object
Set objWord = New Word.Application
objWord.Documents.Add "\\Bulldog\Admin\Copy Of
Analytical Forms Database\FormID.dot"
objWord.Visible = True
If objWord.ActiveDocument.Bookmarks.Exists("Date") =
True Then
objWord.ActiveDocument.Bookmarks("date").Range.Text =
Me!Date

End If

When I click on the command button the word document
opens no data is entered on word form but the following
error shows up for the line before End If

Runtime-error 13 Type Mismatch

Any Help Thank you
 
G

Graham Mandeno

Hi Froto

It seems that Word is having trouble converting the contents of Me!Date into
text. I suggest you try:

objWord.ActiveDocument.Bookmarks("date").Range.Text = _
Me!Date & ""

By adding an empty string to the value, you will force VBA to make the
correct conversion for you.
 

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