0 Replies Latest reply on Jan 23, 2009 9:08 AM by (Archie_Tucker)

    VBScript Duplicating Formatted Text From Tagged Text File

      Working on a VBscript to duplicate formatted text. Below is an example of what I have so far. The problem I have is on the next to last line, how to put the formatted text from the text frame with the placed tagged text file into the new text frame.
      Thanks,
      Archie

      Rem CREATE TEXT FRAMES FUNCTION
      Rem ---------------------------
      Function myCreateFrames (myDocument)

      Set myCurrentFrame = myDocument.TextFrames.Item("myOverFlowFrame")
      myCharacterCount = MyCurrentFrame.Characters.Count

      Rem Get Product Code
      If myCharacterCount > 0 Then
      If left(myCurrentFrame.Texts.Item(1).Contents,9) = "[product=" Then
      myProductLabel = Mid(myCurrentFrame.Texts.Item(1).Contents,10)
      myProductLabel = Split(myProductLabel,"]")(0)' get all to "]"

      Set myLastCharacter = myCurrentFrame.Characters.Item(9 + Len(myProductLabel) + 2)
      myCurrentFrame.Texts.ItemByRange (1,myLastCharacter).Item(1).Contents=""

      End If
      End If

      Rem Get Product Width
      myCharacterCount = MyCurrentFrame.Characters.Count
      If myCharacterCount > 0 Then
      If left(myCurrentFrame.Texts.Item(1).Contents,6) = "[wdth=" Then
      myProductWdth = Mid(myCurrentFrame.Texts.Item(1).Contents,7)
      myProductWdth = Split(myProductWdth,"]")(0)' get all to "]"

      Set myLastCharacter = myCurrentFrame.Characters.Item(6 + Len(myProductWdth) + 2)
      myCurrentFrame.Texts.ItemByRange (1,myLastCharacter).Item(1).Contents=""

      End If
      End If

      Rem Get Product Height
      myCharacterCount = MyCurrentFrame.Characters.Count
      If myCharacterCount > 0 Then
      If left(myCurrentFrame.Texts.Item(1).Contents,6) = "[hght=" Then
      myProductHght = Mid(myCurrentFrame.Texts.Item(1).Contents,7)
      myProductHght = Split(myProductHght,"]")(0)' get all to "]"

      Set myLastCharacter = myCurrentFrame.Characters.Item(6 + Len(myProductHght) + 2)
      myCurrentFrame.Texts.ItemByRange (1,myLastCharacter).Item(1).Contents=""

      End If
      End If

      Rem Create Product Label frame

      Set myTextFrame = myDocument.Textframes.Add

      X1=5
      Y1=5
      myTextFrame.GeometricBounds = Array(Y1, X1, 3 + Y1, myProductWdth + X1)

      myTextFrame.Contents = myProductLabel
      Set myText = myTextFrame.Texts.Item(1)

      With myText
      .AutoLeading = 100
      .BaselineShift = -3
      .FillColor = myDocument.Colors.Item("Red")
      End With

      Rem Create Product Frame

      Set myCurrentFrame = myDocument.TextFrames.Item("myOverFlowFrame")
      Set myCurrentText = myCurrentFrame.Texts.Item(1)
      Set myTextFrame = myDocument.TextFrames.Add

      X1=5
      Y1=11
      myTextFrame.GeometricBounds = Array(Y1, X1, myProductHght + Y1, myProductWdth + X1)
      myTextFrame.Label = "1"

      REM Problem Line Below
      ****** myTextFrame.Texts = myCurrentText *******

      End Function