Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 21st, 2004, 11:38 AM
Authorized User
Join Date: Nov 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Word VBA - Text Form Field

Hi guys,

My Excel workbook currently opens a Word document and passes various data from Excel to text form fields in Word.

Does anyone know how I can dynamically create these text form fields via VBA? I want to search a range and create these text form fields for each item in the range.

Thanks in advance.

Old December 22nd, 2004, 11:09 AM
Friend of Wrox
Join Date: Oct 2003
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts


Try this code
Sub InsertFormFields()
    Dim wdApp As Word.Application
    Set wdApp = New Word.Application
    wdApp.Visible = True
    ' Insert TextBox
    wdApp.Selection.FormFields.Add Range:=wdApp.Selection.Range, Type:= _
    ' Insert CheckBox
    wdApp.Selection.FormFields.Add Range:=wdApp.Selection.Range, Type:=wdFieldFormCheckBox
    ' Insert DropDown
    wdApp.Selection.FormFields.Add Range:=wdApp.Selection.Range, Type:=wdFieldFormDropDown
End Sub


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set memo field text format via VBA dlipkie Access 1 September 25th, 2008 06:54 AM
VBA code to Search All Text Fields on a form dezmond2 BOOK: Access 2007 VBA Programmer's Reference ISBN: 978-0-470-04703-3 1 July 7th, 2007 11:58 AM
Copy text from 1 doc to other doc thru vba in word itchock Word VBA 2 December 29th, 2006 02:47 AM
VBA w/ Word 2000 - Make form on top of everything mvick VB How-To 10 October 2nd, 2006 09:28 AM
Access VBA - Controlling Text boxes in a form Scripts82 Access VBA 4 February 8th, 2006 08:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.