PC Review


Reply
Thread Tools Rate Thread

ACCESS DATA TO MS WORD

 
 
=?Utf-8?B?Um9zZQ==?=
Guest
Posts: n/a
 
      28th Feb 2006
I created a letter in MS word with insert field formula (to merge). On MS
access form design view I added a command button to open MS word application
on click. When I click the MS Word command button it open the letter I
created on the MS word but the data doesn’t merge. This is my code

Private Sub Command63_Click()
On Error GoTo Err_Command63_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Exit_Command63_Click:
Exit Sub

Err_Command63_Click:
MsgBox Err.Description
Resume Exit_Command63_Click

End Sub

 
Reply With Quote
 
 
 
 
Someone
Guest
Posts: n/a
 
      1st Mar 2006
Hi Rose

Your code below simply opens Word and makes it visible. You also need to
tell Access what to do with the data (i.e. what fields need to be merged to
what parts of the Word document). You must add bookmarks to the document
you want the data to be merged to. If you're not too sure how to do this,
just read the help in Word - it should be easy enough to understand (for a
change!)

The following is how you could code the data merge:

With objWord.ActiveDocument
.Bookmarks("FieldName1").Range.Text = Me!ValueInFieldName1.Value
.Bookmarks("FieldName2").Range.Text = Me!ValueInFieldName2.Value
.Bookmarks("FieldName3").Range.Text = Me!ValueInFieldName3.Value
.Bookmarks("DateField").Range.Text = Format(Me!DateField.Value, "dddd d
MMMM yyyy")
.Bookmarks("FieldName4").Range.Text = strField (you can use calculated
fields, for example)
End With

You just repeat the .Bookmarks line as appropriate to fill all fields.

You can also have the file automatically saved, such as:

objDoc.SaveAs FileName:=("C:\file.doc") -this is an exact location
--or--
objDoc.SaveAs FileName:=(strFileName) - you can assemble the location by
code and store it in a string

Does this give you the help you need to complete the merge?

Thanks
M

"Rose" <(E-Mail Removed)> wrote in message
news:1707B5D0-E401-45D8-844D-(E-Mail Removed)...
>I created a letter in MS word with insert field formula (to merge). On MS
> access form design view I added a command button to open MS word
> application
> on click. When I click the MS Word command button it open the letter I
> created on the MS word but the data doesn't merge. This is my code
>
> Private Sub Command63_Click()
> On Error GoTo Err_Command63_Click
>
> Dim oApp As Object
>
> Set oApp = CreateObject("Word.Application")
> oApp.Visible = True
>
> Exit_Command63_Click:
> Exit Sub
>
> Err_Command63_Click:
> MsgBox Err.Description
> Resume Exit_Command63_Click
>
> End Sub
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
data from access to word Maureen Microsoft Word Document Management 1 19th Mar 2008 09:20 AM
Word Mail Merge w/Access Data Base - reports empty data base recor =?Utf-8?B?U3RldmUgUnV0bGVkZ2U=?= Microsoft Access Macros 1 13th Apr 2007 08:48 PM
Access data to Ms Word =?Utf-8?B?Um9zZQ==?= Microsoft Access 0 1st Feb 2006 10:25 PM
Re: Word data to Access John Nurick Microsoft Access External Data 0 28th Sep 2003 09:44 PM
Word data to Access Carol Microsoft Word Document Management 1 26th Sep 2003 11:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:16 PM.