Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-23-2014, 05:53 PM
Ulodesk Ulodesk is offline Setting up a form to bring in text for other documents Windows 7 64bit Setting up a form to bring in text for other documents Office 2013
Word 2013 Expert Cert
Setting up a form to bring in text for other documents
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Setting up a form to bring in text for other documents

I am having problems with a macro from Greg Maxey's site. I can't get the text to come into the document. The requirement is simple. I'm creating a document which will have a number of items listed, each with a check box. The idea is that when a checkbox is checked, the exit macro grabs text from a corresponding document and inserts it at a book mark on a subsequent page.
I created two word docs, Text1 and Text2 on the desktop. Each has just a paragraph or two in it. I copied Greg's macro into my normal template,and replaced his document location and names with mine. I created a trial check box, created a bookmark on the next page, and restricted editing to filling out forms, according, I thought, to his directions on the site page I have now spent 30 minutes looking for and cannot find; it's not in my browser history and no search turns it up.

Anyway, the text is not being brought in.
I am attaching the trial document and the code is below. I have with heavy irony, inserted the name Genius instead of the real user name in the path. I hope someone can quickly spot my error.

Code:
Sub OnExitCB1()
Dim rText As Range
Dim sTrue As String
Dim sFalse As String
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
sTrue = """C:\\Users\\Genius\\Desktop\\Text1.docx"""
sFalse = """C:\\Users\\Genius\\Desktop\\Text2.docx"""
Set rText = ActiveDocument.Bookmarks("Check1Result").Range
If oFld("Check1").CheckBox.Value = True Then
rText , wdFieldIncludeText, sTrue, False
rText.MoveEnd wdCharacter, 1
Else
rText.Fields.Add rText, wdFieldIncludeText, sFalse, False
rText.MoveEnd wdCharacter, 1
End If
With ActiveDocument
.Bookmarks.Add "Check1Result", rText
.Fields.Update
End With
End Sub

Attached Files
File Type: docx Form page.docx (17.0 KB, 13 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up a form to bring in text for other documents Divide Word Form into two separate documents mortcr Word VBA 1 10-22-2013 02:02 PM
Setting up a form to bring in text for other documents Best options for setting tab order in a form DBrooks Word 1 02-16-2013 01:32 PM
Setting up a form to bring in text for other documents Form field selection allows entry into form text box David C Word 1 10-24-2012 04:53 AM
Setting up a form to bring in text for other documents problems saving Word documents in .pdf form kellyjb27 Word 1 05-26-2012 11:08 AM
Setting up a form to bring in text for other documents Form Fields - Create blank form text field with if statement? LAssist2011 Word 5 12-14-2011 03:02 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft