Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 01-09-2014, 01:41 AM
macropod's Avatar
macropod macropod is offline Extract form fields to Word Document Windows 7 32bit Extract form fields to Word Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, all you should need to do is change "MyField" to 4.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #17  
Old 01-09-2014, 02:09 AM
RonNCmale RonNCmale is offline Extract form fields to Word Document Windows 7 64bit Extract form fields to Word Document Office 2003
Novice
Extract form fields to Word Document
 
Join Date: Sep 2012
Posts: 15
RonNCmale is on a distinguished road
Default

I got it to pull the info into the target document, but the information is halfway down the document and is not indented, nor is there a space after the first formfield text. You have done a plenty already and if you say enough is enough, i'll certainly understand. , but can this be tweaked to insert it close to the RE: in the heading, with a indent of the first line of each text with a space between each text.

See attached forms: one is where the text is being placed "halfway down"
the other is where It should be placed with an indention and space.
Attached Files
File Type: doc half way down.doc (24.5 KB, 10 views)
File Type: doc where it should be.doc (23.5 KB, 9 views)
Reply With Quote
  #18  
Old 01-09-2014, 04:04 AM
macropod's Avatar
macropod macropod is offline Extract form fields to Word Document Windows 7 32bit Extract form fields to Word Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by RonNCmale View Post
I got it to pull the info into the target document, but the information is halfway down the document and is not indented, nor is there a space after the first formfield text.
• The 'halfway down' is because you have a bunch of empty paragraphs after the 'Re:'. Click on the ¶ symbol on the Home tab to expose them.
• The lack of indenting is because that's how the last paragraph (the one where the code starts inserting) is formatted that way. If you format the last paragraph with the required attributes, anything inserted by the code will retain that format.
• The lack of a space between paragraphs is because you haven't specified any before/after spacing as part of the paragraph format. You could work around that by adding another '& vbCr' to 'wdTgtDoc.Range.InsertAfter .FormFields(4).Result & vbCr', but that really isn't how it should be done.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #19  
Old 01-11-2014, 03:56 AM
RonNCmale RonNCmale is offline Extract form fields to Word Document Windows 7 64bit Extract form fields to Word Document Office 2003
Novice
Extract form fields to Word Document
 
Join Date: Sep 2012
Posts: 15
RonNCmale is on a distinguished road
Default

I've run into a bit of a quandary!

This code works well and does exactly what I requested, but I have one doc form that has two formfields that need to be extract to the target document, It pulls the formfield 4 on all documents, but I can't get it to pull formfield 1 and formfield 4 on the first document. If it matters, the formfields for the source document that has two formfields are named MyField, and MyField1. It's only on one document.
Reply With Quote
  #20  
Old 01-11-2014, 04:16 AM
macropod's Avatar
macropod macropod is offline Extract form fields to Word Document Windows 7 32bit Extract form fields to Word Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

OK, but how does one identify which document that is (e.g. the name, some unique content) and where the data from the first formfield is to go?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #21  
Old 01-11-2014, 04:25 AM
RonNCmale RonNCmale is offline Extract form fields to Word Document Windows 7 64bit Extract form fields to Word Document Office 2003
Novice
Extract form fields to Word Document
 
Join Date: Sep 2012
Posts: 15
RonNCmale is on a distinguished road
Default

All documents are with different names. Let's call it Form1 for example. This document is the one with two formfields and the first formfield (MyField) should be the first paragraph in the target document followed by formfield two (MyField1).
Reply With Quote
  #22  
Old 01-11-2014, 04:51 AM
macropod's Avatar
macropod macropod is offline Extract form fields to Word Document Windows 7 32bit Extract form fields to Word Document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That suggests the document to which this applies might not be the first one to be opened. Allowing for that possibility -

On the end of:
Dim StrFlds As String, i As Long
add:
, Rng As Range

After:
Set wdTgtDoc = ActiveDocument
insert:
Set Rng = wdTgtDoc.Characters.Last

Change:
wdTgtDoc.Range.InsertAfter .FormFields(4).Result & vbCr
to:
Code:
    If .Name = "Form1.doc" Then
      Rng.InsertBefore .FormFields(1).Result & vbCr & .FormFields(4).Result & vbCr
    Else
      wdTgtDoc.Range.InsertAfter .FormFields(4).Result & vbCr
    End If
and replace "Form1.doc" with whatever the document's name should be.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #23  
Old 01-11-2014, 05:06 AM
RonNCmale RonNCmale is offline Extract form fields to Word Document Windows 7 64bit Extract form fields to Word Document Office 2003
Novice
Extract form fields to Word Document
 
Join Date: Sep 2012
Posts: 15
RonNCmale is on a distinguished road
Default

Wooo hoooo, Works a charm, Thanks again.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting spreadsheet data rows as form fields in a document b3nz Word 3 03-31-2013 07:47 PM
Form Fields in Word jwm1346 Word 1 04-17-2012 07:02 PM
Extract form fields to Word Document Issues with Microsoft Word Form Fields hbforsyth Word 9 11-14-2011 04:26 PM
Calculating Form Fields in Microsoft Word wubba80 Word 1 06-25-2010 12:42 AM
Form fields in Word messed up mba Word VBA 0 02-07-2010 09:54 PM

Other Forums: Access Forums

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


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