none
How to copy paste the Field Values? RRS feed

  • Question

  • Sometimes I need to copy many Field Values and paste them into a Text Document like this:

    DATE \@ "M/d/yyyy"

    TIME \@ "h:mm:ss am/pm"

    I need it especially in the context of the hyperlink. How to do it?

    Thursday, November 22, 2012 9:48 AM

Answers

All replies

  • You mention field values, yet what you show is field codes. Which do you mean

    It's also not clear what you mean by "in the context of the hyperlink". Please elaborate on your requirement and include the version of Word involved.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, November 22, 2012 10:03 AM
    Moderator
  • For a macro to convert field codes to text, see: http://www.gmayor.com/export_field.htm#FieldToText
    And, to convert them back again, see: http://www.gmayor.com/export_field.htm#TextToField

    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by a04 Thursday, November 22, 2012 11:11 PM
    Thursday, November 22, 2012 10:41 AM
  • @Cindy Meister: Fields Codes to Text...

    @macropod: Yes, I think this is the answer.

    1. Is there an option not to have the { } marks?

    2. It's written: "select the field(s) in the document and run the macro". I want to Select all document (Ctrl A), Fileds and other Text. Will it work as well?

    3. I'd glad to know if there is more simpler way to do it, if there is.

    Thank You.

    Thursday, November 22, 2012 4:29 PM
  • If I want all the individual field codes in a document I'd probably do something like this:

    For Each fld in ActiveDocument.Fields
      Debug.Print fld.Code
    End If

    If you have to deal with nested fields, however, this may not be the right solution.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, November 22, 2012 4:35 PM
    Moderator
  • If I want all the individual field codes in a document I'd probably do something like this:

    For Each fld in ActiveDocument.Fields
      Debug.Print fld.Code
    End If

    If you have to deal with nested fields, however, this may not be the right solution.


    Cindy Meister, VSTO/Word MVP, my blog

    I got Compile Error:

    End If without block If

    Thursday, November 22, 2012 5:06 PM
  • With the code in the link, you'll see:

    Select Case CurrChar
    Case Chr(19)
    CurrChar = "{"
    Case Chr(21)
    CurrChar = "}"
    Case Else
    End Select

    Simply change that to:

    Select Case CurrChar
    Case Chr(19)
    CurrChar = ""
    Case Chr(21)
    CurrChar = ""
    Case Else
    End Select

    And yes, if you select the whole document, you'll get the whole document.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by a04 Thursday, November 22, 2012 11:11 PM
    Thursday, November 22, 2012 8:45 PM
  • It works, thanks.
    Thursday, November 22, 2012 11:11 PM
  • sorry, I should have typed Next, not End If

    For Each fld in ActiveDocument.Fields
      Debug.Print fld.Code
    Next


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, November 23, 2012 5:15 PM
    Moderator