Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2014, 08:37 AM
mhblake mhblake is offline Word 2007 Macro Fillin Field to Text Windows XP Word 2007 Macro Fillin Field to Text Office 2007
Novice
Word 2007 Macro Fillin Field to Text
 
Join Date: Dec 2013
Posts: 5
mhblake is on a distinguished road
Default Word 2007 Macro Fillin Field to Text

I have template that I've created with Fillin Fields. These are great for the initial creation of the document, but these go through various iterations and drafts, and it's annoying to have 8-10 pop-up boxes appear every time the document is opened (it's also causing some issues where people hit 'okay' and not 'cancel').

Is there a macro I can run or program a button to that will find and replace just the fillin fields with the static text entered by the user? I don't want to wipe fields out entirely as the documents have active page numbers that need to continue to update correctly.



Any assistance here would be fantastic.

Thanks!
Reply With Quote
  #2  
Old 01-07-2014, 01:02 PM
gmaxey gmaxey is offline Word 2007 Macro Fillin Field to Text Windows 7 32bit Word 2007 Macro Fillin Field to Text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

I suggest you employ a userform for initially creating the document:

http://gregmaxey.com/word_tip_pages/..._userform.html
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 01-07-2014, 02:10 PM
NeilSC NeilSC is offline Word 2007 Macro Fillin Field to Text Windows 7 64bit Word 2007 Macro Fillin Field to Text Office 2013
Novice
 
Join Date: Dec 2013
Posts: 24
NeilSC is on a distinguished road
Default

I think this macro would replace the fill-in fields with the text that shows up as the result after the field is filled in:

Sub UnlinkFillInFields()

Dim myField As Field

For Each myField In ActiveDocument.Fields
If myField.Type = wdFieldFillIn Then
myField.Unlink
End If
Next myField

End Sub
Reply With Quote
  #4  
Old 01-07-2014, 02:38 PM
mhblake mhblake is offline Word 2007 Macro Fillin Field to Text Windows XP Word 2007 Macro Fillin Field to Text Office 2007
Novice
Word 2007 Macro Fillin Field to Text
 
Join Date: Dec 2013
Posts: 5
mhblake is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
I suggest you employ a userform for initially creating the document:

http://gregmaxey.com/word_tip_pages/..._userform.html
Thanks Greg.

I think I'm about 90% there following your instructions, but I think I'm missing something because it doesn't quite work :/

I have a form with 3 text boxes (GrpName, PriorPY, CurrentPY) and two combo boxes (PYMonth1, PYMonth2).

The trouble I'm experiencing is trying to get the data entered in the form into the document. Here's what I have (the "var" reference in VBA matches the field in the word document)

Code:
Option Explicit
Sub AutoNew()
  Create_Reset_Variables
  CallUF
lbl_Exit:
Exit Sub
End Sub
Sub CallUF()
Dim oFrm As frmSurvey
Dim oVars As Word.Variables
Dim strTemp As String
Dim oRng As Word.Range
Dim i As Long
Dim strMultiSel As String
  Set oVars = ActiveDocument.Variables
  Set oFrm = New frmSurvey
  With oFrm
    .Show
      oVars("varGrpName").Value = .txtGrpName
      oVars("varCurrentPY").Value = .txtCurrentPY
      oVars("varPriorPY").Value = .txtPriorPY
      oVars("varPYMonth1").Value = .txtPYMonth1
      oVars("varPYMonth2").Value = .txtPYMonth2
    Else
      MsgBox "Form cancelled by user"
    End If
  End With
  Unload oFrm
  Set oFrm = Nothing
  Set oVars = Nothing
  Set oRng = Nothing
lbl_Exit:
  Exit Sub
End Sub
Anything that jumps out here? I don't need any validation, etc... I just need the data to flow into the document.

Many thanks!
Reply With Quote
  #5  
Old 01-07-2014, 02:57 PM
gmaxey gmaxey is offline Word 2007 Macro Fillin Field to Text Windows 7 32bit Word 2007 Macro Fillin Field to Text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Well, you are missing part of a If conditional statement. You have the Else and End if part put the not IF.

That should be something like:

If .Tag = 1 Then

where Tag is set using the Userform command button e.g.

Sub commandbutton1_Click()
Tag = 1
Hide
End If

You have to have docvariable fields in the document to display the text:

{DocVariable varGrpName} etc.

and add
a Fields.Update command.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 01-08-2014, 08:22 AM
mhblake mhblake is offline Word 2007 Macro Fillin Field to Text Windows XP Word 2007 Macro Fillin Field to Text Office 2007
Novice
Word 2007 Macro Fillin Field to Text
 
Join Date: Dec 2013
Posts: 5
mhblake is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
Well, you are missing part of a If conditional statement. You have the Else and End if part put the not IF.

That should be something like:

If .Tag = 1 Then

where Tag is set using the Userform command button e.g.

Sub commandbutton1_Click()
Tag = 1
Hide
End If
So this works a bit like radio buttons and formulas in Excel (where you can do a conditional such as =if(d3=1,"yes","no") )? Excel is where the vast majority of my very limited experience with VBA lies, so I'm trying to make connections that make sense to me \

What I understand you saying is that within the module, I do the If .Tag = 1 then... and then continue to telling it what to put where?


Quote:
Originally Posted by gmaxey View Post

You have to have docvariable fields in the document to display the text:

{DocVariable varGrpName} etc.

and add
a Fields.Update command.
I do have the docvariable fields in the document and have them named and matching, I think the fields.update is what I'm missing. I'll give this a shot - I greatly appreciate the help!!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2007 Macro Fillin Field to Text Macro to find text and replace with form field containing that text iiiiifffff Word VBA 16 06-04-2016 01:47 AM
Word 2007 Macro Fillin Field to Text MS WORD 2007 - Content Control versus Text Form Field question chamdan Word VBA 2 11-12-2013 09:51 PM
Macro to populate a text form field based on dropdown selection koloa Word 0 10-20-2011 11:52 AM
Word 2007 Macro Fillin Field to Text FILLIN function Andy2011 Word 9 10-19-2011 02:51 PM
Word 2007 Macro Fillin Field to Text Word Macro That Checks a Check Box Form Field When File Print is Executed DKerne Word VBA 4 06-09-2011 11:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:37 AM.


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