Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old December 21st, 2004, 11:38 AM
Authorized User
 
Join Date: Nov 2004
Location: , , .
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.



  #2 (permalink)  
Old December 22nd, 2004, 11:09 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

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

-vemaju



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.