I'm trying to insert a date into a label. I have written the following code. I can select a date by clicking on the arrow and the calendar pops up. The "CANCEL" button is working, but when I click "OK" I cannot get it to insert on the label. The label is a regular Corel document with text and images. I tried inserting a rectangle toolbox to see if I can get it to insert the date in there by using X,Y coordinates but that didn't work.
I basically need to know how to insert DTPicker.Value
onto the label.
Sub ShowIt()
Calendar.Show
End Sub
Private Sub Cancel_Click()
Unload Me
End Sub
Private Sub OK_Click()
a = DTPicker1.Value
b = Format(DTPicker1.Value, "mm/dd/yy")
Unload Me
End Sub
Private Sub DTPicker1_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker1.Value = Format(DTPicker1.Value, "mm/dd/yy")
End Sub
Private Sub Calendar_Activate()
Me.DTPicker1.Value = Date
End Sub
Thank you!
Try to run the previous code separated from your code.
Sub Macro1()
ActiveDocument.ReferencePoint = cdrCenter
XPos = Activeselection.PositionX
YPos = Activeselection.PositionY
Set s = ActiveLayer.CreateArtisticText(0, 0, CStr(Date))
s.PositionX=XPos
s.PositionY=YPos
End Sub
- Select the rectangle
- Click macro
The macro should work perfectly to create and place date at center on rectangle. BUT, the date is NOW (date when macro executed).
Then you should modify " CStr(Date)" to the value where the date is referred.
Try This :
1. Add a button on macro form
2. Select the rectangle
3. Click the button
4. Macro will read X, Y Pos of the rectangle, then create text and positioning it on the center of the rectangle
ActiveDocument.ReferencePoint = cdrCenter
XPos = Activeselection.PositionX 'XPos of the rect
YPos = Activeselection.PositionY 'YPos of the rect
Set s = ActiveLayer.CreateArtisticText(0, 0, CStr(Date))
s.PositionX=XPos
s.PositionY=YPos
The below code should work as requested :
ActiveDocument.ReferencePoint = cdrCenter
XPos = Activeselection.PositionX 'XPos of the rect
YPos = Activeselection.PositionY 'YPos of the rect
Set s = ActiveLayer.CreateArtisticText(0, 0, CStr(Date))
s.PositionX=XPos
s.PositionY=YPos
BUT :
He did not use Corel Draw..... :)
https://community.coreldraw.com/talk/coreldraw_community/f/101/t/51007
"Object variable or With block variable not set".
No Active document there.
I think you should create NEW Document first