0

I have written a document that uses variables in field codes, so when the system is updated, I only need to update one location in the document. i.e.: {Set SWVersion "3.5.2" \*MergeFormat}

I'm hoping to use this same field in a file naming convention description in the document, but need to replace . with _. e.g. Name your file Project_V3_5_2_Stage1

I was hoping for something like {Replace SWVersion "." "_" \*MergeFormat}.

Does any such function exist? Would I need a macro? I've searched through the help files and didn't spot any replace function. So I guess I'd need a second field, and a macro that updates the value of the second field based on the first?

Thanks for your help.

Scott
  • 161
  • 5
  • 13
  • Are you sure that you are using VBA? Your code looks more like C#. By "variables" are you referring to https://learn.microsoft.com/en-us/office/vba/api/word.variables – Timothy Rylatt May 05 '23 at 14:36
  • 1
    You're trying to use the Word "field code language" which does not support the kind of text-related functions you may be used to in VBA or general-purpose languages. In this case, IMO the simple answer is to have another field that says something like { SET SWVersionU "3_5_2" }. – jonsson May 05 '23 at 18:18

0 Answers0