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 03-11-2014, 02:51
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default Move focus from Object Manager to Drawing

I have this macro for selecting objects on the activelayer:

Code:
Dim l As Layer, s As Shape

For Each s In ActivePage.Shapes
If s.Type <> cdrTextShape Then s.AddToSelection

Next s

For Each s In ActiveSelection.Shapes

    If s.Type = cdrGroupShape Then
       
      tc = 0
       
           For Each ss In s.Shapes
           If ss.Type = cdrTextShape Then tc = tc + 1
           sc = sc + 1
           Next ss
           
          ' MsgBox "Sc = " & sc & ", tc = " & tc
           
           If sc = tc And tc > 0 Then
              s.RemoveFromSelection
           End If
                  
    End If
        
Next s

The problem is with the focus. If I click a layer in the object manager and tnen run the macro it selects all non-text objects but the focus remains on the object manger so when I press an arrow ley expecting to move the selected objects they stay put. How to get the focus back to the drawing? Thanks.
Reply With Quote
  #2  
Old 03-11-2014, 17:11
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Version

You still on X4?

-Shelby
Reply With Quote
  #3  
Old 04-11-2014, 13:32
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

Hi, Shelby. I'm using X6.
Reply With Quote
  #4  
Old 04-11-2014, 20:20
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Macro

How are you running the macro, on icon on a toolbar? I gave it a shot and it worked.

Your code doesn't respect the layer, it is searching the entire page. But it does move with the arrow keys.

mmmm, I must be doing something wrong.

-Shelby
Reply With Quote
  #5  
Old 07-11-2014, 21:34
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default

I'm running the macro from a keyboard shortcut. The macro was just a bad example. The problem is with where the focus is within CorelDraw itself. If I select a layer in the Object Manager (Current Page, Layers Only) and run macro that selects objects the focus remains on the Object Manager so that when I use the arrow keys I change the layer selection in the Object Manager. I have a kind of fix using tab keys to shift the focus back to the drawing. Here's the code I'm now using:

Code:
Sub selectcurrentlayerimages() 'i

Dim l As Layer, s As Shape

If ActiveSelection.Shapes.Count = 0 Then
Set l = ActiveLayer

For Each s In ActiveLayer.Shapes
If s.Type <> cdrTextShape Then s.AddToSelection
Next s

Sendkeys "{tab} {tab}"

Else

For Each s In ActiveLayer.Shapes
If s.Type <> cdrTextShape Then s.RemoveFromSelection
Next s

End If

End Sub
I'd prefer it if I didn't have to use sendkeys but it gets round my problem. Hope I've made it clearer now. Thanks
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
How to avoid using CorelScript object when drawing in PhotoPaint svc4 Corel Photo-Paint VBA 1 23-04-2011 14:55
One property of Object Manager ager CorelDRAW/Corel DESIGNER VBA 0 07-07-2010 04:54
Move object to 0,0 CWCN General 1 15-06-2010 13:55
Move an object norbert_ds CorelDRAW/Corel DESIGNER VBA 6 01-05-2007 19:58
Sorting entries in the object manager dan CorelDRAW/Corel DESIGNER VBA 1 18-08-2004 22:16


All times are GMT -5. The time now is 13:54.


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