This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Corel Macro - Insert Date, replace text object

Hi.  I have this code to insert the current date into a blank document.  However, I would like to tweak it so that it replaces text with and ID of "Date".  This should be easy but I'm still a little lost on how to do this.

Sub InsertDate()
' Get the current date
Dim currentDate As String
currentDate = Format(Date, "mm/dd/yyyy") ' Or use your desired format

' Get the active document
Dim activeDoc As Object
Set activeDoc = ActiveDocument

' Get the active layer
Dim activeLayer As Object
Set activeLayer = activeDoc.ActiveLayer

' Create a text object
Dim textObject As Object
Set textObject = activeLayer.CreateArtisticText(0, 0, currentDate)

' Position the text object (adjust as needed)
textObject.PositionX = 10 ' Example: 10 mm from the left edge
textObject.PositionY = 10 ' Example: 10 mm from the top edge

End Sub