Replacing text in large numbers of Tag Group files.

-Randy Keup

11/24/1999

The current format for tag group files is some fragmented binary thing.

That coupled with the fact that the tag group editor doesn't do either search and replace or batch conversions of CSV files to TGD (the binary format), means that one has to edit the CSV version in your favorite editor and then for each file, open it in the tag group editor as a CSV file, then save it as a TGD file. For a few files this isn't a big deal, but for large numbers of files and multiple changes over time, it is a pain. The VB script below will automate the opening and saving of the files in the tag group editor. You will still have to search and replace in your favorite editor before doing this. This is basically a replacement of the Convert... menu command in the Tag Group Editor.

Put the script below into your Project_User - Modules area in FIX VB.

Create a new Module under it.

Just assemble your list of files and there you go.

You might want to try this on a test file first.

You must make sure that the TGD versions of the files don't already exist or a Replace File? window will pop up and the keystroke sequences will get screwed up. ( Can you tell I did that?)

Sub ConvertTagGroups()

Dim i As Long

Dim ReturnValue

ReturnValue = Shell("D\Dynamics\TagGroupEditor.exe", 1)

Dim Start

Start = Timer ' Set start time.

Do While Timer < Start + 3

DoEvents ' Yield to other processes.

Loop

AppActivate ReturnValue

' Here is where you loop over your files calling ConvertToTGD

' The file name is just the name, no dot or extension

Dim fileName As String

' for each file in list

ConvertToTGD fileName

' next

End Sub

Private Sub ConvertToTGD(fileName As String)

' The delay loops are to give the windows time to pop up, otherwise

' key strokes get lost

' Make sure you are not doing other things while this is running

' otherwise the window focus will be lost.

' In other words, just start this macro and sit back until it

' finishes.

SendKeys "^o", True

Dim Start

Start = Timer ' Set start time.

Do While Timer < Start + 1

DoEvents ' Yield to other processes.

Loop

Dim inFile As String

inFile = fileName & ".csv"

SendKeys inFile & "~", True

Start = Timer ' Set start time.

Do While Timer < Start + 1

DoEvents ' Yield to other processes.

Loop

SendKeys "%f", True

SendKeys "{DOWN}{DOWN}{DOWN}~", True

Start = Timer ' Set start time.

Do While Timer < Start + 1

DoEvents ' Yield to other processes.

Loop

SendKeys fileName & "~", True

Start = Timer ' Set start time.

Do While Timer < Start + 1

DoEvents ' Yield to other processes.

Loop

End Sub