PC Review


Reply
Thread Tools Rate Thread

Populate word document

 
 
=?Utf-8?B?THVpcw==?=
Guest
Posts: n/a
 
      2nd Aug 2007
Hello.
I'm trying to populate a Word document from an Access table. The word
document has a table and i've added bookmarks to all the cells.
The problem is that when i try to put data on that table 2 weird things
happen. The first is that alltough i change the bookmark, the data is always
written on the first bookmark. The second is that it can't find the bookmark.
Can anyone help me?
The code i'm using is the following:

Dim objWord As Object
Dim objMergeDoc As Object
Dim rs As DAO.Recordset

On Error Resume Next
Set objWord = GetObject("Word.application")

If Err.Number <> 0 Then
Set objWord = CreateObject("word.application")
End If

Err.Clear
Application.FollowHyperlink "\\faial\Ddr\vol1\BD_Valorizacao\NI.rtf"

objWord.Visible = True
objWord.Activate

Set rs = CurrentDb.OpenRecordset("PAs_NotaInterna")
rs.MoveFirst

Book_mark = 1

Do
PA = rs!PA

bkMrk = "PA" & Book_mark
objWord.Bookmarks(bkMrk).Select
objWord.Selection.text = PA
objWord.Refresh
rs.MoveNext
Book_mark = Book_mark + 1
Loop While Not rs.EOF

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFuaWVs?=
Guest
Posts: n/a
 
      2nd Aug 2007
I would urge you to take a look at Albert D. Kallal's 'Super Easy Word Merge'
which can be found at

http://www.members.shaw.ca/AlbertKal.../msaccess.html
--
Hope this helps,

Daniel P





"Luis" wrote:

> Hello.
> I'm trying to populate a Word document from an Access table. The word
> document has a table and i've added bookmarks to all the cells.
> The problem is that when i try to put data on that table 2 weird things
> happen. The first is that alltough i change the bookmark, the data is always
> written on the first bookmark. The second is that it can't find the bookmark.
> Can anyone help me?
> The code i'm using is the following:
>
> Dim objWord As Object
> Dim objMergeDoc As Object
> Dim rs As DAO.Recordset
>
> On Error Resume Next
> Set objWord = GetObject("Word.application")
>
> If Err.Number <> 0 Then
> Set objWord = CreateObject("word.application")
> End If
>
> Err.Clear
> Application.FollowHyperlink "\\faial\Ddr\vol1\BD_Valorizacao\NI.rtf"
>
> objWord.Visible = True
> objWord.Activate
>
> Set rs = CurrentDb.OpenRecordset("PAs_NotaInterna")
> rs.MoveFirst
>
> Book_mark = 1
>
> Do
> PA = rs!PA
>
> bkMrk = "PA" & Book_mark
> objWord.Bookmarks(bkMrk).Select
> objWord.Selection.text = PA
> objWord.Refresh
> rs.MoveNext
> Book_mark = Book_mark + 1
> Loop While Not rs.EOF
>

 
Reply With Quote
 
=?Utf-8?B?THVpcw==?=
Guest
Posts: n/a
 
      2nd Aug 2007
Thanks for the hint.

"Daniel" wrote:

> I would urge you to take a look at Albert D. Kallal's 'Super Easy Word Merge'
> which can be found at
>
> http://www.members.shaw.ca/AlbertKal.../msaccess.html
> --
> Hope this helps,
>
> Daniel P
>
>
>
>
>
> "Luis" wrote:
>
> > Hello.
> > I'm trying to populate a Word document from an Access table. The word
> > document has a table and i've added bookmarks to all the cells.
> > The problem is that when i try to put data on that table 2 weird things
> > happen. The first is that alltough i change the bookmark, the data is always
> > written on the first bookmark. The second is that it can't find the bookmark.
> > Can anyone help me?
> > The code i'm using is the following:
> >
> > Dim objWord As Object
> > Dim objMergeDoc As Object
> > Dim rs As DAO.Recordset
> >
> > On Error Resume Next
> > Set objWord = GetObject("Word.application")
> >
> > If Err.Number <> 0 Then
> > Set objWord = CreateObject("word.application")
> > End If
> >
> > Err.Clear
> > Application.FollowHyperlink "\\faial\Ddr\vol1\BD_Valorizacao\NI.rtf"
> >
> > objWord.Visible = True
> > objWord.Activate
> >
> > Set rs = CurrentDb.OpenRecordset("PAs_NotaInterna")
> > rs.MoveFirst
> >
> > Book_mark = 1
> >
> > Do
> > PA = rs!PA
> >
> > bkMrk = "PA" & Book_mark
> > objWord.Bookmarks(bkMrk).Select
> > objWord.Selection.text = PA
> > objWord.Refresh
> > rs.MoveNext
> > Book_mark = Book_mark + 1
> > Loop While Not rs.EOF
> >

 
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
Outlook 2k7 - create and populate new word document in VBA Molly Coddlez Microsoft Outlook VBA Programming 0 18th Mar 2011 04:06 PM
Can I 'auto' populate a field in a word document? =?Utf-8?B?Z290dGEgcXVlc3Rpb24=?= Microsoft Frontpage 2 9th Feb 2007 02:14 AM
Macro is Excel to populate a word document Andrew Microsoft Excel Misc 0 6th May 2004 06:26 PM
populate word document via asp.net Stephen Witter Microsoft Dot NET 1 11th Feb 2004 05:12 PM
Populate word document Leigh Microsoft Word Document Management 3 23rd Jul 2003 01:57 PM


Features
 

Advertising
 

Newsgroups
 


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