Hello,
I'm new with corel macros, need some help:)
I'm making tickets and i need to add tickets numbers, from 1 to 1000. Print & Merge doesnt fit for me.
So I want to change text tag for example: "<text>" to text witch will be different (1, 2 ,3 ,4 ,5 ,6 ,7 ...)
I found an post in this forum from Hendrik Wagenaar where the code finds word "Andorra" and change it to "Andorre". Maybe where is simple way to modify this code, that it could work to make increasing numbers.
CODE:
Public Function FindReplace(ByVal str As String, ByVal toFind As String, ByVal toReplace As String) As String Dim i As Integer For i = 1 To Len(str) If Mid(str, i, Len(toFind)) = toFind Then ' does the string match? FindReplace = FindReplace & toReplace ' add the new replacement to the final result i = i + (Len(toFind) - 1) ' move to the character after the toFind Else FindReplace = FindReplace & Mid(str, i, 1) ' add a character End If Next iEnd Function
Public Sub TextTranslate() Dim s As Shape ActiveDocument.BeginCommandGroup "Text Translate" For Each s In ActiveDocument.ActivePage.Shapes If s.Type = cdrTextShape Then s.Text.Story = FindReplace(s.Text.Story, "Andorra", "Andorre") s.Text.Story = FindReplace(s.Text.Story, "Albania", "Albanie") End If Next s ActiveDocument.EndCommandGroupEnd Sub
wyy said:I'm making tickets and i need to add tickets numbers, from 1 to 1000. Print & Merge doesnt fit for me. So I want to change text tag for example: "<text>" to text which will be different (1, 2 ,3 ,4 ,5 ,6 ,7 ...)
Check this macro, it in comes with several others in a package for under 10.00 USD.
Hi,
Well i figured out..
here the code, if somebody interested:
Public Function FindReplace(ByVal str As String, ByRef sk As Integer, ByVal toFind As String, ByVal toReplace As String) As String
Dim i As Integer
For i = 1 To Len(str)
If Mid(str, i, Len(toFind)) = toFind Then ' does the string match?
sk = sk + 1
FindReplace = FindReplace & toReplace & sk ' add the new replacement to the final result
i = i + (Len(toFind) - 1) ' move to the character after the toFind
Else
FindReplace = FindReplace & Mid(str, i, 1) ' add a character
End If
Next i
End Function
Public Sub TextTranslate()
Dim s As Shape
Dim sk As Integer
sk = 0
ActiveDocument.BeginCommandGroup "Text Translate"
For Each s In ActiveDocument.ActivePage.Shapes
If s.Type = cdrTextShape Then
s.Text.Story = FindReplace(s.Text.Story, sk, "<nr>", "V0" & i)
Next s
ActiveDocument.EndCommandGroup
End Sub