OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-10-2010, 03:44
eo04837
Guest
 
Posts: n/a
Default File Converter Issue

I am trying to extract the first page out of a large number of CDRs in X4. I am trying to use the fileconverter macro to convert from CDR to CDR while selecting "save each page as a separate file".

However, the output I get doesn't actually save separate pages, I get several new files (the correct number based on how many pages there are), but each file includes all of the pages (though oddly enough, they are all slightly different sizes). If I convert to CMX, it seems to work fine, but I need CDR.

Can anyone confirm that what I want to do is actually possible, or have any ideas for solutions (aside from manually extracting each page...not a fun way to spend a day).

Thanks,
Ed
Reply With Quote
  #2  
Old 03-10-2010, 10:44
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
Try modifying the code in frmFileConverter as shown in the snippet below:

Code:
Else 'cdr file
                If PageAsSeparateFile Then
                    Dim myOpts As New StructSaveAsOptions 'added <<<<<<<<<<<<<<<
                    myOpts.Range = cdrCurrentPage 'added <<<<<<<<<<<<<<<
                    For Each p In d.Pages
                        CurFileName = GetNewFileName(frmSourceSelection.lstSelectedFiles.List(n), cboFileFormat.Text, DestDir, p.Index)
                        p.Activate
                        d.SaveAs CurFileName, myOpts 'modified <<<<<<<<<<<<<<<<
                    Next p
                Else
-John
Reply With Quote
  #3  
Old 03-10-2010, 12:07
eo04837
Guest
 
Posts: n/a
Default

Hi John,

Thank you so much for your help. I pasted the new code in, but get an error saying:

Error saving the file 'C:\temp\ALBER 36-1.cdr'
Parameter Range cannot be 1

I think I inserted the code in the right place (it wasn't specifically labeled CDR, but was the only one that matched). Please let me know if I should have put it somewhere else, or done something different.

Thanks,
Ed

Code:
'converts files using the current settings
Private Sub ConvertFiles()
    Dim n As Integer
    Dim d As Document
    Dim ex As ExportFilter
    Dim SourceDir As String
    Dim flt As cdrFilter
    Dim DestDir As String
    Dim p As Page
    Dim se As StructExportOptions
    Dim si As New StructImportOptions
    Dim pal As StructPaletteOptions
    Dim nStage As Long
    Dim CurFileName As String, Ret As VbMsgBoxResult
    
    Set d = Nothing
    nStage = 0 ' Out of file conversion loop
    On Error GoTo ErrHandler
    Me.MousePointer = fmMousePointerHourGlass
    If IsRaster(cboFileFormat.Text) Then
        Set se = GetStructExport(cboFileFormat.Text)
        Set pal = PALOptions.SetProperties
    Else
        Set se = CreateStructExportOptions
    End If
    se.UseColorProfile = ApplyColorProfile
    SourceDir = txtSource.Text
    DestDir = txtDestination.Text
    si.CombineMultilayerBitmaps = True
    si.MaintainLayers = True
    flt = GetFilterType(cboFileFormat.Text)
    'append a backslash if there isn't already one
    If Right$(SourceDir, 1) <> "\" Then SourceDir = SourceDir & "\"
    If Right$(DestDir, 1) <> "\" Then DestDir = DestDir & "\"
    For n = 0 To frmSourceSelection.lstSelectedFiles.ListCount - 1
        nStage = 1 ' Opening a file
        Set d = Nothing
        CurFileName = SourceDir & frmSourceSelection.lstSelectedFiles.List(n)
        If PageAsSeparateFile And UCase$(Right$(CurFileName, 4)) = ".CDR" Then
            Set d = OpenDocument(CurFileName)
        Else
            Set d = CreateDocument
            d.ActiveLayer.Import CurFileName, , si
        End If
        
        If UseBackgroundColor Then
            SetBackgroundColor
        End If
        
        If d.Pages.Count > 1 Or d.Selection.Shapes.Count > 0 Then
            nStage = 2 ' Processing the file
            'set the page size
            If UsePage Then
                If cboUnits.ListIndex = 0 Then
                    d.Pages(0).SetSize Val(txtPageHeight.Text), Val(txtPageWidth.Text)
                Else
                    d.Pages(0).SetSize Val(txtPageHeight.Text / INCHES_TO_MILLIMETERS), Val(txtPageWidth.Text / INCHES_TO_MILLIMETERS)
                End If
            End If
            
            nStage = 3 ' Saving the file
            'export the file
            If cboFileFormat.Text <> CDR_FILE And cboFileFormat.Text <> DES_FILE Then
                If PageAsSeparateFile Then
                    For Each p In d.Pages
                        CurFileName = GetNewFileName(frmSourceSelection.lstSelectedFiles.List(n), cboFileFormat.Text, DestDir, p.Index)
                        p.Activate
                        Set ex = d.ExportEx(CurFileName, flt, cdrCurrentPage, se, pal)
                        GetExportOptions cboFileFormat.Text, ex
                        ex.Finish
                        Set ex = Nothing
                    Next p
                Else
                    CurFileName = GetNewFileName(frmSourceSelection.lstSelectedFiles.List(n), cboFileFormat.Text, DestDir)
                    Set ex = d.ExportEx(CurFileName, flt, cdrCurrentPage, se, pal)
                    GetExportOptions cboFileFormat.Text, ex
                    ex.Finish
                    Set ex = Nothing
                End If
            Else 'cdr file
                If PageAsSeparateFile Then
                    Dim myOpts As New StructSaveAsOptions 'added <<<<<<<<<<<<<<<
                    myOpts.Range = cdrCurrentPage 'added <<<<<<<<<<<<<<<
                    For Each p In d.Pages
                        CurFileName = GetNewFileName(frmSourceSelection.lstSelectedFiles.List(n), cboFileFormat.Text, DestDir, p.Index)
                        p.Activate
                        d.SaveAs CurFileName, myOpts 'modified <<<<<<<<<<<<<<<<
                    Next p
                Else
                    CurFileName = GetNewFileName(frmSourceSelection.lstSelectedFiles.List(n), cboFileFormat.Text, DestDir)
                    d.SaveAs CurFileName
                End If
            End If
        End If
NextFile1:
        nStage = 4 ' Closing the file
        If Not d Is Nothing Then
            d.Dirty = False 'set the dirty flag and ...
            d.Close  'close the doc
            Set d = Nothing
        End If
NextFile2:
    Next n
ExitSub:
    If Not d Is Nothing Then
        d.Dirty = False 'set the dirty flag and ...
        d.Close  'close the doc
        Set d = Nothing
    End If
    Me.MousePointer = fmMousePointerDefault
    Exit Sub
ErrHandler:
    Select Case nStage
        Case 1 ' Open
            Ret = MsgBox("Unable to open the file '" & CurFileName & "'" & vbCr & Err.Description, vbCritical + vbAbortRetryIgnore)
            If Ret = vbAbort Then Resume ExitSub
            If Ret = vbRetry Then Resume
            If Ret = vbIgnore Then Resume NextFile1
        Case 2 ' Processing
            Ret = MsgBox("Error processing the file '" & CurFileName & "'" & vbCr & Err.Description, vbCritical + vbAbortRetryIgnore)
            If Ret = vbAbort Then Resume ExitSub
            If Ret = vbRetry Then Resume
            If Ret = vbIgnore Then Resume NextFile1
        Case 3 ' Saving
            Ret = MsgBox("Error saving the file '" & CurFileName & "'" & vbCr & Err.Description, vbCritical + vbAbortRetryIgnore)
            If Ret = vbAbort Then Resume ExitSub
            If Ret = vbRetry Then Resume
            If Ret = vbIgnore Then Resume NextFile1
        Case 4 ' Closing
            Ret = MsgBox("Error occured while trying to close a document" & vbCr & Err.Description, vbCritical + vbAbortRetryIgnore)
            If Ret = vbAbort Then Resume ExitSub
            If Ret = vbRetry Then Resume
            If Ret = vbIgnore Then Resume NextFile2
        Case Else
            MsgBox "Unexpected error occured" & vbCr & Err.Description, vbCritical
            Resume ExitSub
    End Select
End Sub
Reply With Quote
  #4  
Old 03-10-2010, 17:48
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
Did you only insert the 2 lines and modify the other?
-John
Reply With Quote
  #5  
Old 04-10-2010, 10:13
eo04837
Guest
 
Posts: n/a
Default

Yes, I only added the two lines and modified the third. I don't do much with macros, aside from just changing values now and then, so I could easily be missing something obvious though. I tried just pasting in the lines you added and the myOpts to the third line, and I also just tried cutting and pasting the whole segment with the same result.

My fileconverter.gsm was from 2005, I think, is that correct? It's possible I somehow pulled in an old one when moving around macros.

Thanks again for your help!
Reply With Quote
  #6  
Old 04-10-2010, 10:18
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

HI.
Try this mod instead.

Code:
Else 'cdr file
                If PageAsSeparateFile Then
                    Dim myOpts As New StructSaveAsOptions 'added <<<<<<<<<<<<<<<
                    myOpts.Range = cdrSelection 'added <<<<<<<<<<<<<<<
                    For Each p In d.Pages
                        CurFileName = GetNewFileName(frmSourceSelection.lstSelectedFiles.List(n), cboFileFormat.Text, DestDir, p.Index)
                        p.Activate
                        ActivePage.Shapes.All.CreateSelection 'added  <<<<<<<<<<<<<
                        d.SaveAs CurFileName, myOpts 'modified <<<<<<<<<<<<<<<<
                    Next p
                Else
-John
Reply With Quote
  #7  
Old 05-10-2010, 03:44
eo04837
Guest
 
Posts: n/a
Default

That worked great John, now Corel needs to pay you to include it in their next SP!

Thanks a ton for your help, you really saved me!
Reply With Quote
  #8  
Old 05-10-2010, 09:23
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
Glad to hear.
X5 seems to have a different version of the file converter already.
-John
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
File converter suggestion vallentin Macros/Add-ons 6 28-09-2005 21:50
File Converter script error CorelDummy CorelDRAW/Corel DESIGNER VBA 2 25-01-2005 09:38
SOME CHANGES OVER FILE CONVERTER olympiatr CorelDRAW/Corel DESIGNER VBA 2 14-04-2004 03:05
File Converter - turning off layers venturian CorelDRAW/Corel DESIGNER VBA 6 27-01-2004 09:08
Problem with File Converter CMX->EPS starless Macros/Add-ons 4 09-05-2003 09:33


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


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