I searched all over the place, but there was not anybody explaining how to call up a windows Font or Color Dialog. The CorelDraw developers site was not very helpful in this regard, but it did hold clues with the Corel Script Tools reference for GetFont and GetColors. I just had to figure out the syntax for getting the code to work in my VBA macro. So here is the form and the code in my hunt for how to do this. It requires a form, a label "enter your text here", a text box, a blank label, and four buttons. View text shows what the text will look like before you complete it in the blank label. Clear text will clear the text and reset the focus to the text box. Create Artistic Text will put the text centered on the page. Exit, of course, does its thing.
Option Explicit'Declare variables that need to be accessible publicallyDim FontName$, PtSize&, Wt&, Itlc As Boolean, underl As Boolean, StrkOut As BooleanDim myRed&, myGreen&, myBlue&
Private Sub UserForm_Initialize()'This causes the font dialog to load these variables or else it is blankFontName = "Arial"PtSize = 20Wt = 400End Sub
Private Sub cmdCreate_Click()'you must set the corelscripttool as an object and then the other variablesDim cst As Object, ChsFont As Boolean, RegBold As Boolean, col As Boolean, LettrColor As Long'This tells you there is not any text enteredIf txtInput = "" Then MsgBox "You need to enter text to proceed", vbOKOnly, "Enter Text" txtInput.SetFocus 'This resets the focus back to the textboxElse 'this sets the object to corel script tools Set cst = CorelScriptTools 'You need a boolean variable to access the corel script tools object 'in order to assign the variable using the windows font dialog ChsFont = cst.GetFont(FontName, PtSize, Wt, Itlc, underl, StrkOut, myRed, myGreen, myBlue) 'You need a boolean variable to access the corel script tools object 'in order to assign the variable using the windows color dialog col = cst.GetColor(myRed, myGreen, myBlue) 'This allows you to assign a color to forecolor of a label LettrColor = RGB(myRed, myGreen, myBlue)End If'converts a number to bold true or falseIf Wt < 700 Then RegBold = FalseElse RegBold = TrueEnd If'This sets the label types to match the font characteristicsWith lblDisplay .Caption = txtInput .Font.Name = FontName .ForeColor = LettrColor .Font.Size = PtSize .Font.Bold = RegBold .Font.Italic = Itlc .Font.Underline = underl .Font.Strikethrough = StrkOutEnd With'it is always good to clear out the memory by setting the object to nothingSet cst = NothingEnd Sub
Private Sub cmdArtText_Click()'This creates the Artistic text with the approved variable valuesDim LeftSize#, BttmSize#, CreateTxt$, RegBold As Boolean, Uline&'This is to center the created text on the pageLeftSize = ActivePage.SizeWidth / 2BttmSize = ActivePage.SizeHeight / 2CreateTxt = txtInput'The Weight of the font is returned as a long, but to create the text with corel you need it to be Boolean'400 is the regular font wt and 700 is boldIf Wt < 700 Then RegBold = FalseElse RegBold = TrueEnd If'In the corel GetFont the underline is boolean, but in corel it takes a number 0 for none and 3 for thick lineIf underl = True Then Uline = 3Else Uline = 0End If'This actually creates the artistic textActiveLayer.CreateArtisticText LeftSize, BttmSize, CreateTxt, cdrEnglishUS, , FontName, PtSize, RegBold, Itlc, Uline, cdrCenterAlignment'This changes the color to the color selectedActiveSelection.Fill.UniformColor.RGBAssign myRed, myGreen, myBlueEnd Sub
Private Sub cmdClearText_Click()'This clears the text box and the label and sets focus to the text boxtxtInput = ""lblDisplay.Caption = ""txtInput.SetFocusEnd Sub
Private Sub cmdExit_Click()Unload MeEnd Sub
Hope this helps someone in need!