OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 31-07-2006, 08:04
Posts: n/a
Default adding jpg to textbox

Has anyone try to insert a jpg file or bmp file to a textbox
This can be manually in corel 11.

I have this code where mytext is my textbox where I insert addingtext,

How would it be my syntaxis to insert into textbox a file instead a text

mytext.Text.Story.InsertAfter "addingtext"
Reply With Quote
Old 21-08-2006, 22:03
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4

The only way you can do this is through the clipboard. Copy your bitmap (or other object) to the clipboard (using Shape.Copy or Shape.Cut methods) and then paste it into the text object using TextRange.Paste method.

Note that TextRange.Paste replaces the whole content of the text range with the objects from the clipboard (that is, as if the whole text in the range was selected and then you start typing - which effectively replaces the selected characters with the new ones).

If you want to paste an object after a range, you need to construct a range which will point right past the end of the current range. You can use TextRange.Collapse method to do it quickly.

Here is a sample macro which creates a rectangle, converts it into a bitmap. Copies the bitmap to the clipboard and creates a paragraph text object with some text in it, then pastes the bitmap at the end of the text object:

Sub InsertBitmapIntoText()
    Dim s As Shape
    Dim sBitmap As Shape
    Dim tr As TextRange
    Set s = ActiveLayer.CreateRectangle(0, 0, 2, 2)
    s.Fill.ApplyTextureFill "Aerial clouds", "Samples"
    Set sBitmap = s.ConvertToBitmapEx(cdrCMYKColorImage, Resolution:=120)
    Set s = ActiveLayer.CreateParagraphText(0, 2, 2, 4, "Some Text")
    Set tr = s.Text.Story
    tr.Collapse True ' Make an empty text range which is at the end of the text
    tr.Paste ' Paste the bitmap into the current (empty) text range
End Sub
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding an info box to all drawings mamos General 4 04-05-2006 13:41
Adding text via VBA knowbodynow CorelDRAW/Corel DESIGNER VBA 2 03-03-2006 09:15
Adding controls to forms at runtime ddonnahoe CorelDRAW/Corel DESIGNER VBA 15 20-12-2005 13:59
Adding a toolbar button to a script (.csc) file Alex FAQ 0 27-04-2005 12:12
Adding a Reference on a pwd protected macro Rick Randall CorelDRAW/Corel DESIGNER VBA 9 27-10-2004 09:27

All times are GMT -5. The time now is 23:19.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com