OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > Corel Script > CorelDRAW CS

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 30-01-2012, 06:58
Shail
Guest
 
Posts: n/a
Default Export & Import Text Strings in .CDR file

Hello All,

Is there any way to export & Import the text strings from .CDR file using Corel Scripts or VBA?

Thanks,
Shail
Reply With Quote
  #2  
Old 30-01-2012, 08:00
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Export Text Strings

Here is a simple way to export the text strings on the current page. Hopefully it will get you started.
Code:
Sub ExportText()
    Dim s As Shape
    
    Open "D:\Temp\MyText.txt" For Output As #1
    
    For Each s In ActivePage.FindShapes(Type:=cdrTextShape)
        Print #1, s.Text.Story
    Next s
    
    Close #1
End Sub
-Shelby
Reply With Quote
  #3  
Old 31-01-2012, 04:00
Shail
Guest
 
Posts: n/a
Default

Hello,

Thanks for the code. I have modified to achieve my requirements. However, stuck in auto generating ID's for id attribute for source element....
Code:
Sub Export2XML()
Dim s As Shape
Dim xmlFile
    xmlFile = "D:\Temp\cdrStr.xml"
    
    Open xmlFile For Output As #1
    Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & _
              " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>"
              '' <  add xml-schema if it's needed here >
        Print #1, "<cdrstrings>"
        
        For Each s In ActivePage.FindShapes(Type:=cdrTextShape)
        
            Print #1, "<source id="">"
            Print #1, s.Text.Story
            Print #1, "</source>"
            Print #1, "<target>"
            Print #1, s.Text.Story
            Print #1, "</target>"
        Next s
        Print #1, "</cdrstrings>"
        Close #1
End Sub
Reply With Quote
  #4  
Old 31-01-2012, 07:17
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Id

What would you like the source ID to be? You could use s.StaticID

-Shelby
Reply With Quote
  #5  
Old 01-02-2012, 01:41
Shail
Guest
 
Posts: n/a
Default

Thanks! my requirement is export the text strings translate it and import back.
Is there any way to import back the strings in .cdr file using the same script.

Thanks,
Shail
Reply With Quote
  #6  
Old 09-02-2012, 15:57
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Text Strings

If you use the StaticID in your XML file, then when you need to import the new string you would find the shape with the StaticID and change the text to the new string. It should work just fine.

-Shelby
Reply With Quote
  #7  
Old 29-03-2012, 03:52
Shail
Guest
 
Posts: n/a
Default

Thanks a Lot!
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
Need help spliting strings in coreldraw ashishbindal93 Macros/Add-ons 5 18-12-2011 00:19
Import text file to create shapes jess916 Macros/Add-ons 3 12-08-2008 20:21
Urgent: Coreldraw 3x: how to export all the pages in .CDR file into one .SVG file balan CorelDRAW/Corel DESIGNER VBA 1 21-05-2008 07:47
How to import values from a file, replace text,save file for each value with new name amaart CorelDRAW/Corel DESIGNER VBA 1 28-09-2007 12:41
Export text file from corel sript?! ceda CorelDRAW CS 0 06-06-2003 04:19


All times are GMT -5. The time now is 14:31.


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