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 25-03-2006, 01:52
akayani
Guest
 
Posts: n/a
Default Handling objects on Master Pages

Alex & Others,

I'm just putting error trapping and stuff in place to cope with odd cases... such as locked objects.

With this code that searches the document for bitmaps...

Got any advice on how I should deal with master pages. Currently objects on master pages are process repeatedly when each page in processed.

I think I just want to skip processing them altogether.

How are these objects identified in code?


Yani
Reply With Quote
  #2  
Old 27-03-2006, 01:54
amollondhe
Guest
 
Posts: n/a
Default Explain

Can You Explain More Clearly!!!!!
I Think I Know The Problem,i Have Worked With It.
Reply With Quote
  #3  
Old 27-03-2006, 02:39
akayani
Guest
 
Posts: n/a
Default

"Currently objects on master pages are process repeatedly when each page in processed."

I couldn't find any references to Master Page objects in any of the VBA help material.

I have and If then statement and could just add something to avoid these objects if I knew who they are referenced.

I did concider locking master layers but this didn't stop the objects being processed.

Alternatively I could lock each master page object which will stop them being processed.

Either way I need to discover how to reference them.

Yani
Reply With Quote
  #4  
Old 27-03-2006, 09:13
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Sample code, Yani... Sample code

Need to see what you are doing exactly to suggest any better way of doing what your are doing...
Reply With Quote
  #5  
Old 27-03-2006, 10:08
akayani
Guest
 
Posts: n/a
Default

Oh Alex that is just me feeling guilty cause you've done the work for me...

Code:
Case 2 'This Document

On Error GoTo ErrorHandler

 Response = MsgBox("Warning all bitmaps in the current DOCUMENT will be converted as per your settings!", 1)
    If Response = 1 Then
        Dim cp As Pages
        Dim p As Page
        Dim n As Integer
        Dim nNumOfPages As Integer
        'Get the total number of pages and apply to cp variable
        Set cp = ActiveDocument.Pages
        nNumOfPages = cp.Count
        'Loop through the Pages referenced in the cp variable and activate the actual page then search for bitpmaps for conversion
        For Each p In cp
             p.Activate
             For Each SelectedBitmap In ActivePage.Shapes.FindShapes(Type:=cdrBitmapShape)
                If SelectedBitmap.Type = cdrBitmapShape Then
                   If AllImages = False Then
                        If SelectedBitmap.Bitmap.Mode = SelectedType Then
                            ProcessBitmap SelectedBitmap 'Calls the bitmap processing
                        End If
                   Else
                   ProcessBitmap SelectedBitmap 'Calls the bitmap processing
                   End If
                End If
             Next SelectedBitmap
        Next p
    Else
    End If
Exit Sub
I couldn't find any references on how to refer to master page objects. In retrospect I guess it is via layers?

Yani
Reply With Quote
  #6  
Old 27-03-2006, 11:11
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Yani,

You can get the layer a particular bitmap is on and see if it is a master layer or not. You can also check beforehand if the layer is editable (and not hidden) and if the bitmap is not locked in order to eliminate the chance of runtime error (even though you have an error handler, it is still better to avoid the errors in the first place, in my opinion).

If you use CorelDRAW 12 or X3, you will have a special shape collection on Page object called "SelectableShapes". This collection only includes objects that can be selected by the user, that is, no locked objects or objects on non-editable/hidden layers will be included in this collection. By using it, you will spare yourself all the trouble:

Code:
Sub ConvertToGrayscale()
    Dim bmp As Shape
    Dim p As Page
    
    For Each p In ActiveDocument.Pages
        p.Activate
        For Each bmp In p.SelectableShapes.FindShapes(Type:=cdrBitmapShape)
            If Not bmp.Layer.Master Then
                bmp.Bitmap.ConvertTo cdrGrayscaleImage
            End If
        Next bmp
    Next p
End Sub
If you want to convert master objects specifically, you can just iterate through objects which are on the Master page:

Code:
Sub ConvertMasterBitmapsToGrayscale()
    Dim bmp As Shape
    
    For Each bmp In ActiveDocument.MasterPage.SelectableShapes.FindShapes(Type:=cdrBitmapShape)
        bmp.Bitmap.ConvertTo cdrGrayscaleImage
    Next bmp
End Sub
Reply With Quote
  #7  
Old 27-03-2006, 19:16
akayani
Guest
 
Posts: n/a
Default

Perfect...

And yea I had used an Error Handler to cheat. Spank Me!

Yani
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
Import PDF with multiple pages. rsriram22 CorelDRAW/Corel DESIGNER VBA 1 20-03-2006 11:54
Totally Confused - Group of 1 objects? knowbodynow CorelDRAW/Corel DESIGNER VBA 4 08-03-2006 17:56
Glitches with Names of Objects Granite Golem CorelDRAW/Corel DESIGNER VBA 14 01-06-2005 04:38
Need help accessing objects in a group ama CorelDRAW/Corel DESIGNER VBA 5 20-02-2004 12:28
I need to update objects visibility faster NEHovis Corel Photo-Paint VBA 0 18-07-2003 08:54


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


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