![]() |
#1
|
|||
|
|||
![]()
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. ![]() |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
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? |
#5
|
|||
|
|||
![]()
What happen if file contain more then one page?
I will have to run script for evry page or.... |
#6
|
|||
|
|||
![]() Quote:
Thanks for your opinion. All opinions. |
#7
|
|||
|
|||
![]()
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 |
#8
|
|||
|
|||
![]() Quote:
|
#9
|
|||
|
|||
![]()
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 |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 05:33 |
files import | graphicdesigner | CorelDRAW/Corel DESIGNER VBA | 11 | 20-11-2004 00:56 |
Read Data from Excel File | LxRAE | CorelDRAW/Corel DESIGNER VBA | 5 | 14-04-2004 03:10 |
Would you miss CorelScript object? | Alex | CorelDRAW/Corel DESIGNER VBA | 32 | 04-02-2004 15:59 |
Corel Capture 8 and Corel Script | Helix | CorelDRAW CS | 0 | 13-12-2002 19:10 |