Subject: | win32::ole does not find classes from CorelDraw type library that VB 2005 and Corel VBA can use |
Date: | Tue, 30 Jan 2007 19:18:51 +0100 |
To: | bug-libwin32 [...] rt.cpan.org |
From: | Maximilian Heise <max.heise [...] anacomp-iberica.com> |
Hello,
i'm evaluating win32::ole for some automation of repetitive tasks (file
conversion).
Unfortunately the following line gives an error message:
my $exportFilter = Win32::OLE->new('CorelDRAW.ExportFilter');
==>>
Win32::OLE(0.1707) error 0x800401f3: "Cadena clase no vßlida" at
C:\Documents an
d Settings\bonsai\Escritorio\ablage\perl-ole\test1.pl line 49
eval {...} called at C:\Documents and
Settings\bonsai\Escritorio\ablage\
perl-ole\test1.pl line 49
I'm using Corel Draw 12.0+SP1 and ActivePerl 5.8.8 Build 819 on a WinXP
laptop with SP2 installed.
Using the Win32::Ole type library browser in IE in can see the:
Corel - CorelDraw 12.0 Library
Library CorelDRAW
C:\Archivos de programa\Corel\Corel Graphics 12\Programs\draw12vba.chm
Corel - CorelDRAW 12.0 Library
I then found a bit of VB 2005 Express Studio code on the net and with VB
in can successfully talk with CorelDRAW.ExportFilter, i also recorded a
macro in Corel Draw that uses ExportFilter.
Could you please maybe look into this? Or alternatively give me enough
pointers so i can try to look myself ?
My perl code (very simple) that does not work:
#!/usr/bin/perl -w
###
# Packages
###
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Enum;
use Win32::OLE::Const 'Corel - CorelDRAW';
print "Passed package loading\n";
###
# Warnings
###
Win32::OLE->Option(Warn => 3);
###
# Open Application
###
my $CDR = Win32::OLE->GetActiveObject('CorelDRAW.Application')
|| Win32::OLE->new('CorelDRAW.Application');
die "Error getting handle\n" unless $CDR;
print "Got application handle\n";
###
# Visibility on
###
$CDR->{'Visible'} = 1;
###
# Get a document to operate on
###
if ( $CDR->ActiveDocument() ) {
print 'File already loaded, FullFileName: ',
$CDR->ActiveDocument()->FullFileName(), "\n";
} else {
print 'Currently no document loaded', "\n";
$CDR->OpenDocument("C:\\data_exchange\\test.cdr")
|| die "Error loading file\n";
print 'New File loaded, FullFileName: ',
$CDR->ActiveDocument()->FullFileName(), "\n";
}
print "Got a document handle\n";
###
# Get export filter
###
my $exportFilter = Win32::OLE->new('CorelDRAW.ExportFilter');
###
# Get struct palette
###
my $structPalette = Win32::OLE->new('CorelDRAW.StructPaletteOptions');
My VB code (shamelessly copied from the url below) that works:
' Adapted from:
' Rob Cohen
' Match Development, LLC
' Cleveland, Ohio
' 06-06-2006, 15:52
' http://forum.oberonplace.com/showthread.php?t=1548&page=2
Module Module1
Sub Main()
Dim objDraw As New CorelDRAW.Application
Dim pal As CorelDRAW.StructPaletteOptions
Dim EXP As CorelDRAW.ExportFilter
pal = objDraw.CreateStructPaletteOptions
With objDraw.ActivePage
.SelectShapesFromRectangle(0, 0, .SizeWidth, .SizeHeight, True)
End With
With pal
.PaletteType = CorelDRAW.cdrImagePaletteType.cdrPaletteOptimized
.NumColors = 16
.Smoothing = 0
.DitherType = CorelDRAW.cdrDitherType.cdrDitherNone
.ColorSensitive = False
End With
EXP =
objDraw.ActiveDocument.ExportBitmap("C:\\data_exchange\\test2.gif", _
CorelDRAW.cdrFilter.cdrGIF,
CorelDRAW.cdrExportRange.cdrSelection, _
CorelDRAW.cdrImageType.cdrPalettedImage, 225, 225, 72, 72, _
CorelDRAW.cdrAntiAliasingType.cdrNormalAntiAliasing, False,
False, False, False, _
CorelDRAW.cdrCompressionType.cdrCompressionNone, pal)
With EXP
.Interlaced = False
.Transparency = 0 ' FilterGIFLib.gifNone
.InvertMask = False
.ColorIndex = 1
End With
EXP.Finish()
pal = Nothing
EXP = Nothing
objDraw = Nothing
End Sub
End Module
And finally the recorded macro that works to:
Sub dxf_export_aufgezeichnet()
'
' Recorded 30/01/2007
'
' Description:
' aufgezeichnetes Makro dxf export
'
Dim expflt As ExportFilter
Dim expopt As StructExportOptions
Set expopt = New StructExportOptions
expopt.UseColorProfile = False
Set expflt = ActiveDocument.ExportEx("C:\data_exchange\test3.dxf",
cdrDXF, cdrAllPages, expopt)
With expflt
.BitmapType = 0 ' FilterDXFLib.dxfBitmapJPEG
.TextAsCurves = True
.Version = 0 ' FilterDXFLib.dxfVersion2002
.Units = 4 ' FilterDXFLib.dxfCentimeters
.FillUnmapped = True
.Finish
End With
End Sub
In the end another question: How do i get rid of the Spanish error msgs?
Like this one:
Win32::OLE(0.1707) error 0x800401f3: "Cadena clase no vßlida" at
C:\Documents an
I'd like to have English ones.
Thanks
BR
Max