Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Reference the name of a formfield bookmark in Word

I am filling in a form letter in Word using data from my excel worksheet. I
am using Formfields which I am new at. I know how to reference a specific
bookmark name like:

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application.11")
appWD.ActiveDocument.FormFields("Contact_Name").Se lect

My question is, can I reference a bookmark name by a value in my worksheet.
For example, something like:

appWD.ActiveDocument.FormFields activecell.offset(1,2).value.select

I keep getting an error. Would anyone know the exact syntax or method to do
this?

Thanks!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Reference the name of a formfield bookmark in Word


"sharonm" schreef in bericht
...
I am filling in a form letter in Word using data from my excel worksheet. I
am using Formfields which I am new at. I know how to reference a specific
bookmark name like:

Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application.11")
appWD.ActiveDocument.FormFields("Contact_Name").Se lect

My question is, can I reference a bookmark name by a value in my
worksheet.
For example, something like:

appWD.ActiveDocument.FormFields activecell.offset(1,2).value.select

I keep getting an error. Would anyone know the exact syntax or method to
do
this?

Thanks!



Running Office 2000...


Option Explicit

'I have a sample sheet with these cells:
'- C3: Name
'- C5: Address
'- C7: Zipcode
'- C9: City

'In a Word document (same path) I added
'4 bookmarks:
'bmName, bmAddress, bmZipcode, bmCity

'References added in VB Editor:
'Microsoft Word 9.0 Object Library

Public Sub xlsCells2wrdBookmarks()

'declare objects
Dim wb As Workbook
Dim ws As Worksheet
Dim wrdApp As Word.Application
Dim wrdDoc As Document

'assign object values
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1")
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(wb.Path & "\" & "BOOKMARKS.doc")

'Run Word on the background
wrdApp.Visible = False
wrdDoc.Activate

wrdApp.Selection.Goto wdGoToBookmark, , , "bmName"
wrdApp.Selection.TypeText Text:=ws.Cells(3, 3).Value

wrdApp.Selection.Goto wdGoToBookmark, , , "bmAddress"
wrdApp.Selection.TypeText Text:=ws.Cells(5, 3).Value

wrdApp.Selection.Goto wdGoToBookmark, , , "bmZipcode"
wrdApp.Selection.TypeText Text:=ws.Cells(7, 3).Value

wrdApp.Selection.Goto wdGoToBookmark, , , "bmCity"
wrdApp.Selection.TypeText Text:=ws.Cells(9, 3).Value

wrdDoc.Save
wrdDoc.Close
wrdApp.Quit

'clean up
Set wrdDoc = Nothing
Set wrdApp = Nothing
Set ws = Nothing
Set wb = Nothing

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking to a bookmark in a Word doc ibvalentine Excel Discussion (Misc queries) 0 April 25th 08 12:27 AM
formfield in word document through excel movi1982 Excel Discussion (Misc queries) 0 July 17th 06 07:53 AM
hyperlink from Excel to a Word bookmark Bertie Excel Discussion (Misc queries) 2 May 16th 06 07:51 PM
Pipe a Paragraph to a bookmark in Word LookingGood Excel Programming 1 March 9th 06 01:57 PM
IsEmpty and bookmark help with excel 97 and word 97 JMCN Excel Programming 0 July 15th 04 05:31 PM


All times are GMT +1. The time now is 08:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"