Hi,
I'm trying to modify a Corel Drawing programatically using VB.net rather than VBA. I don't seem to be able to do simple things such as FindShape. I've added the CorelDRAW reference library but to no avail... Here's an example of what I want to do:
Dim S as ShapeDim TextToInsert As String
TextToInsert = “New Text”
Set S = ActiveLayer.Shapes.FindShape("SignatureEnglish") ‘should finds your objects named SignatureEnglish – this is case sensitive
If S Is Nothing Then GoTo Ending: ‘if it doesn’t find the shape, go to endEnd if
If Not S Is Nothing And S.Type = cdrTextShape Then ‘if S is anything AND it’s a cdrTextShape object…S.Text.Story = TextToInsert ‘inserts the text in your string variable…
End If
Ending:
Can someone help with this please? Or tell me what's going on in VB.net vs. VBA?
Thanks!
Vibeke
Dim s As Shape
For Each s In ActivePage.ShapesIf s.Name = "signatureenglish" Thens.Name = "foundit"End IfIf s.Type = cdrTextShape Thens.Text.Story = "New Text"End IfNext s
Thank you Michael for your response. I'm still not able to make it work though.
The first line I've changed to: Dim s As CorelDRAW.Shape
The second line "ActivePage" is underlined with the following comment: "Name 'ActivePage' is not declared". I seem to be stuck here. I'm new to this so bear with me please :-).
Thanks Again
Try to declare a Shell at first like a "Sub-" or a "Function-"Command, for example:
Sub YourDesiredSubName()
Dim s As ShapeFor Each s In ActivePage.ShapesIf s.Name = "signatureenglish" Thens.Name = "foundit"End IfIf s.Type = cdrTextShape Thens.Text.Story = "New Text"End IfNext s
End Sub
I still have the same problem... "Name 'ActivePage' is not declared". Help?
Dim s As CorelDRAW.Shape
For Each s In CorelDRAW.ActivePage.ShapesIf s.Name = "signatureenglish" Thens.Name = "foundit"End IfIf s.Type = cdrTextShape Thens.Text.Story = "New Text"End IfNext s
I still can't get it to work, it now says: "'ActivePage' is not a member of 'CorelDRAW'"
thanks
I have some doubt, that the object library of CorelDraw is really referenced.
Did you saved the macro after you have referenced the Draw Object library? That's important, cause otherwise the reference get lost.
Pick it again in the Reference List under the .COM-Tab, declare a reference object with
"Dim drwApp As CorelDRAW.Application
Public Sub Macro()
...
and save the macro. The "Public" Command makes it available for other Projects.
Still the same problem, I've saved, rebuilt, etc...