我正在尝试在标签中插入日期。我写了以下代码。我可以通过单击箭头选择日期,然后弹出日历。 “CANCEL”按钮正在工作,但是当我点击“确定”时,我无法将其插入标签上。标签是带有文本和图像的常规Corel文档。我尝试插入一个矩形工具箱,看看我是否可以通过使用X,Y坐标来插入日期,但这不起作用。
我基本上需要知道如何在标签上插入DTPicker.Value
。
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
谢谢!
答案 0 :(得分:0)
试试这个: 1.在宏窗体上添加一个按钮 2.选择矩形 3.单击按钮 4.宏将读取矩形的X,Y Pos,然后创建文本并将其定位在矩形的中心
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
答案 1 :(得分:0)
尝试运行与代码分开的先前代码。
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
宏应该可以完美地创建并将日期放在矩形的中心。但是,日期是NOW(宏执行的日期)。
然后你应该将“CStr(Date)”修改为引用日期的值。
答案 2 :(得分:0)
以下代码应按要求运行:
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
但是: 他没有使用Corel Draw ..... :) https://community.coreldraw.com/talk/coreldraw_community/f/101/t/51007
答案 3 :(得分:-1)
"对象变量或With块变量未设置"。
那里没有活动文件。
我认为你应该首先创建新文档