OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 27-02-2008, 07:28
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default Reverse TextBox

Quick question...

I have this...

Dim S as Shape
Set S = ActiveLayer.Shapes.FindShape("test")
S.Text.Story = Textbox1.Value

In my .cdr file I have an artist text thats labeled test in the object data manager... if I open a form and type something in the text box... it types whats in the text box, in my artist text in the .cdr file - I got this part down no problem...

NOW... the question is, how can I do that in reverse? When I open the form (script under userform_initialize), it looks to see what the artistic text is (in object data "test") and fills it in as the value in textbox1 in the form ...

is this possible?
Reply With Quote
  #2  
Old 27-02-2008, 08:06
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

there are form's events Initialize and other: in the form's code view select first combobox just above the code pane, select UserForm (now an empty sub appears), immediately choose Initialize event in the second nearby combobox - now you have the UserForm_Initialize() event. Type the assignments there
Reply With Quote
  #3  
Old 27-02-2008, 08:15
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default

hi os, I got that part... the part I need is "reading" the artistic text in my document, and inserting it into the textbox1.value when the form starts.

I can make it insert text into my corel file from the textbox1 in the form, but I need to do the reverse... using the object data name I want to find a particular peice of artistic text in my corel file, and upon opening my userform it populates textbox1.value with the artist text I found in the corel file using "object data"

I have "templates" set up that I use a userform I made, to fill in a number of items in my template/corel file. What I now want it to do is, if I save the template/corel file and open it at a later date... upon starting the userform, it populates all the text fields using the data that is already in my saved corel file... so I can modify or erase using the form, rather then doing it in the corel file itself!
Reply With Quote
  #4  
Old 27-02-2008, 08:21
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

I assume you use some shape iteration to find a shape with the data field required when you tranfser the text from the form.

Code:
sub userform_Initialize()
  dim sh as shape
  for each sh in activePage.FindShapes(,cdrTextShape)
    if sh.DataBlabla... then 'FOUND 1
      textbox1=sh.Text.Story.Text
    elseif blabla2 ' FOUND 2
      textbox2=sh.Text.Story.Text
    ......
    endif
  next
end sub
Reply With Quote
  #5  
Old 27-02-2008, 08:38
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default

Hi Os,
I modified slightly and came up with this and it works!

Code:
Private Sub userform_Initialize()
Dim S As Shape
Set S = ActiveLayer.Shapes.FindShape("doctext", cdrTextShape)
TextBox1 = S.Text.Story.Text
End Sub
Your "TextBox1 = S.Text.Story.Text" is what made my script work... I just couldn't figure out how to get the text found in "doctext" into TextBox1 ... now I got it!

Appreciate the help!

B
Reply With Quote
  #6  
Old 27-02-2008, 08:41
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

yeah, these text properties are somewhat tricky, yet powerful :-)

btw, paying tribute to my obsession with optimizations and error checking:
Code:
Private Sub userform_Initialize()
  on error resume next
  TextBox1 = ActiveLayer.FindShape("doctext", cdrTextShape).Text.Story.Text
End Sub
Reply With Quote
  #7  
Old 27-02-2008, 08:51
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default

Quote:
Originally Posted by wOxxOm View Post
btw, paying tribute to my obsession with optimizations and error checking:
hahaha that said... you'd have a heart attack if you looked at the code I do! I am a beginner at best... so optimization means nothing to me... lol. i write what works for my knowledge & skill level ... and well.... i'm sure it's horrible... but it works! I have things that have 100's upon 100's of lines of code... and I'm sure in the right hands... could be done is as few as 50 or 60 lines!

the in house IT guy checks in occasionally and looks at my work... and although he has a limited knowledge as well (light years head of mine) he just shakes his head when he see's the code in my scripts! hahaha

thanks again!

B
Reply With Quote
  #8  
Old 27-02-2008, 08:53
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

:-)
it's ok, I've just had a chance to feed my demon
Reply With Quote
Reply


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 jpg to textbox donjuan CorelDRAW/Corel DESIGNER VBA 1 21-08-2006 22:03


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


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