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 20-06-2004, 06:42
alex69
Guest
 
Posts: n/a
Default Is Corel to Excel data exchange possible?

I have two corel and xls file. In corel file i have text laike "X123", "X124", "X125" and so on under pictures in some products. In xls file, data is structured on this way - first column: "X123", "X124", "X125" ; on second column: price for "X123", "X124", "X125" ; and in tdird column: weight for "X123", "X124", "X125" .
So i want to get price and weight for evry single number "X123", "X124", "X125" in xls file and add them in corel file in right place for evry single number "X123", "X124", "X125".
So can you help me haw to make search for text object in corel file and add formatetd content to it, and haw to get corect data from excel file.
:?:
Reply With Quote
  #2  
Old 21-06-2004, 05:40
Sebastian
Guest
 
Posts: n/a
Default Re: Is Corel to Excel data exchange possible?

It's shame to post such a mess like I'm doing now but I hope it will help you some way.
I apologize all the programming purists.
Code:
Function Translate8700GER()
    Dim xl As Object
    Dim n As Long
    Dim sCellValue As String
    Dim y As Double
    
    'Set xl = GetObject(, "Excel.Application")
    
    'For n = 1 To 763
    '    sCellValue = xl.Cells(n, 1).Value
    'Next n
Dim objExcel As Excel.Application
Dim objWBK As workBook
Dim objSh As workSheet
tm = Timer
'Otwieramy Excela i dodajemy nowy skoroszyt
Set objExcel = New Excel.Application
Set objWBK = objExcel.Workbooks.Open("i:\sps\names\sebastian\!seba\slowka - ger - 8700.xls")
Set objSh = ActiveSheet
objExcel.Visible = True
    
On Error Resume Next
'For Each dok In Application.Documents
Dim s As Shape
Dim sr As ShapeRange
Set sr = ActivePage.FindShapes(Type:=cdrTextShape)
objExcel.Range("a1").Activate
objExcel.Visible = True

frmPodglad.Show
If Right(strDirName, 1) <> "\" Then strDirName = strDirName & "\"
varFileArray = GetAllFilesInDir(strDirName, "cdr")
For lngI = 0 To UBound(varFileArray)
CorelScript.FileOpen (strDirName & varFileArray(lngI))
Set sr = ActivePage.FindShapes(Type:=cdrTextShape)
For Each s In sr
        'temp = s.Text.FontProperties(cdrAllFrames).Value
        'If s.Text.Contents = "SWIATLA POSTOJOWE, COFANIA I STOPU" Then Stop
        temp = s.Text.Contents: 'If Asc(Left(temp, 1)) = 32 Then temp = Right(temp, Len(temp) - 1)
        If temp = "" Or Left(temp, 1) = "*" Or Len(temp) < 3 Then GoTo a:
        objExcel.Columns("A:A").Find(What:=temp, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True).Activate
        If Err.Number <> 91 Then
            If Err.Number = 0 Then
                If Len(objExcel.Cells(ActiveCell.Row, 2)) > 0 Then
                    If objExcel.Cells(ActiveCell.Row, 2) = "X" Then
                        s.Text.Replace temp, " ", False: Err.Clear: GoTo a:
                        Else
                        s.Text.Replace temp, objExcel.Cells(ActiveCell.Row, 2), False: Err.Clear: GoTo a:
                    End If
                    Else
                    GoTo a:
                End If
            End If
           MsgBox Err.Number & Err.Description: Stop
            Else
            Err.Clear
            objExcel.Range("a1").Activate
            GoTo a:
        End If
        objExcel.Range("a1").Activate
        Columns("A:A").Select
        'For n = 1 To 763
        '    temp2 = objExcel.Cells(n, 1).Value
        '    s.Text.Replace temp, temp2, False
        '
        'Next n
a:
Err.Clear
Next s
CorelScript.FileSave strDirName & "TRANS_" & varFileArray(lngI), 0, 0, 0, 0
CorelScript.FileClose
Next lngI
'Next dok
'objExcel.Application.Quit
'MsgBox 1
objExcel.Visible = True
Set objSh = Nothing
objWBK.Close
Set objWBK = Nothing
objExcel.Quit
Set objExcel = Nothing
'objExcel.ActiveWorkbook.Close
'Set objExcel = Nothing
MsgBox Timer - tm & "sekund"
End Function
Reply With Quote
  #3  
Old 22-06-2004, 02:02
alex69
Guest
 
Posts: n/a
Default Re: Is Corel to Excel data exchange possible?

Hi Sebastian!
Tank you for your help! Itr was intresting ;-)!
I atached two cdr and excel file to show exactly my problem( my english is not the best ;-), so i'm not shure thet my explanation was good!), and i'm hope that somone program purist ;-) will give us his opinion!

P.S. Here is one more question: can i use CDRStaticID for eny porpose in this case?
Attached Files
File Type: xls Book1.xls (58.5 KB, 934 views)
File Type: cdr 1n.cdr (46.7 KB, 945 views)
File Type: cdr 1n.cdr (46.7 KB, 889 views)
Reply With Quote
  #4  
Old 22-06-2004, 08:27
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Is Corel to Excel data exchange possible?

Sebastian,

I'm just curious, why do you use CorelScript to open/close documents? Is there a reason for this?
Reply With Quote
  #5  
Old 23-06-2004, 00:53
alex69
Guest
 
Posts: n/a
Default Another question!

What happen if file contain more then one page?
I will have to run script for evry page or....
Reply With Quote
  #6  
Old 23-06-2004, 02:14
Sebastian
Guest
 
Posts: n/a
Default Re: Is Corel to Excel data exchange possible?

Quote:
Originally Posted by Alex
Sebastian,

I'm just curious, why do you use CorelScript to open/close documents? Is there a reason for this?
Hmmm. I'm very lazy quasi-programmer and I haven't even thought about other solution if this one works. It was at the beginnig of my work with Corel VBA and I had to show something to my boss quickly so I'd need to be fast and had no time for learning more.
Thanks for your opinion. All opinions.
Reply With Quote
  #7  
Old 23-06-2004, 07:48
alex69
Guest
 
Posts: n/a
Default

Sebastian what type is variable "temp".
I have compile error "User defaine type not defined" fro:
Dim objExcel As Excel.Application
Dim objWBK As workBook
Dim objSh As workSheet





elin_s2001@yahoo.com
Reply With Quote
  #8  
Old 24-06-2004, 00:16
Sebastian
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by alex69
Sebastian what type is variable "temp".
I have compile error "User defaine type not defined" fro:
I didn't define the type of 'temp' so it's variant.
Reply With Quote
  #9  
Old 24-06-2004, 04:52
alex69
Guest
 
Posts: n/a
Default NEXT QUESTION ;-)

Do you know some way to get string from ArtsticTextShape and put them in string variable(or to get number of cheracters form TextShape and put them in long type variable - t.Story.Characters.Count)?
The problem is thet "s.Text.Replace sCellValue, CStr(n), False, ReplaceAll:=True" can't do difference betwin ArtisticTextShape like "X1", "X11", "X111" and make replace for all like for "X1" so i want to compare strings before replacement and then do it.


Sub Test2()
Dim s As Shape, n, m As String
Dim i, temp As Long
Dim xl As Object
Dim id As String
Dim gram, price As String
Dim t As Text
Set xl = GetObject(, "Excel.Application")
For i = 1 To 1000
id = xl.Cells(i, 1).Value
gram = xl.Cells(i, 2).Value
price = xl.Cells(i, 3).Value

n = id + Chr$(13) + Str(gram) + Chr$(13) + Str(price)

For Each s In ActivePage.FindShapes(, cdrTextShape)


s.Text.Replace id, CStr(n), False, ReplaceAll:=True
Next s
Next i
End Sub
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
Reading from an Excel and Putting it into Corel all_ashish CorelDRAW/Corel DESIGNER VBA 6 23-04-2007 04:33
files import graphicdesigner CorelDRAW/Corel DESIGNER VBA 11 19-11-2004 23:56
Read Data from Excel File LxRAE CorelDRAW/Corel DESIGNER VBA 5 14-04-2004 02:10
Would you miss CorelScript object? Alex CorelDRAW/Corel DESIGNER VBA 32 04-02-2004 14:59
Corel Capture 8 and Corel Script Helix CorelDRAW CS 0 13-12-2002 18:10


All times are GMT -5. The time now is 21:22.


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