Seleting objects instead of cells ??

keldsor

Board Regular
Joined
Jun 9, 2017
Messages
52
I have a workbook with a worksheet with a lot of shapes like DOT.

Each dot represents an event and I can get the details for a specific event shown in Word by double clicking on the DOT for the event I want to see the details for.

I HAVE to do "double clicking" for the details to show up in Word AND bring Word in front on the screen, BUT ...

unfortunately this "double clicking" takes Excel out of "Selecting objects"-mode and inte "Selecting cells"-mode !

When I opens the workbook I have this code to secure it opens in "Select objects"-mode:

Code:
Private Sub Workbook_Open()
    If ActiveSheet.Shapes.Count > 0 Then Application.CommandBars.ExecuteMso "ObjectsSelect"
End Sub

How can I sort of "lock the workbook in that "Select-Objects-mode" ?
 
Naaaaaahr ... it's simply NOT stable !

Sometimes it WILL bring Word in front by just SINGLE click and sometimes it NEEDs a double click ...

BUT the "Select objects"-mode is ALWAYS on with the last code change - that's good !
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Naaaaaahr ... it's simply NOT stable !

Sometimes it WILL bring Word in front by just SINGLE click and sometimes it NEEDs a double click ...

BUT the "Select objects"-mode is ALWAYS on with the last code change - that's good !

Normally, when you insert an object as an icon onto a worksheet , you must double click the icon to open the actual object ... A single click dosen't work.

Do you have a macro attached to the Word icon dots ?!!
 
Upvote 0
Normally, when you insert an object as an icon onto a worksheet , you must double click the icon to open the actual object ... A single click dosen't work.

Do you have a macro attached to the Word icon dots ?!!

I took a copy of your posting #2 :

"I guess you have a macro assigned to each object in order to open Word - Right? If so then you should just click the objects (shapes) ... no need to double-click them. "

I'm using "shapes" not icons - does it make a difference ?

Yeah, I have a sub "attached" to the ."OnAction" for every one of these DOTs.

It works nicely WHEN it works ... the problem is why only "sometimes" ?
 
Upvote 0
I took a copy of your posting #2 :

"I guess you have a macro assigned to each object in order to open Word - Right? If so then you should just click the objects (shapes) ... no need to double-click them. "

I'm using "shapes" not icons - does it make a difference ?

Yeah, I have a sub "attached" to the ."OnAction" for every one of these DOTs.

It works nicely WHEN it works ... the problem is why only "sometimes" ?

Well, if you have a macro attached to each shape to open the word doc then, in theory, it should work consistetly with a single click.

Can you upload a demo workbook that produces the problem you are experiencing to a file share website like Box.com or another site so I can take a look ?
 
Upvote 0
It's way too big and complicated to upload ...

The sub on the ".OnAction" is not a sub to directly open Word ... it's a sub to let Access open Word and show a document !

I've done it this way because I with a checkmark can choose to open Word document (from Access) OR just show the event in Access.

But I don't think this could have influence on the "sometimes" - right ?

Is it some "delay" problems ?
 
Upvote 0
It's way too big and complicated to upload ...

The sub on the ".OnAction" is not a sub to directly open Word ... it's a sub to let Access open Word and show a document !

I've done it this way because I with a checkmark can choose to open Word document (from Access) OR just show the event in Access.

But I don't think this could have influence on the "sometimes" - right ?

Is it some "delay" problems ?
I guess the issue lies somwhere in the code of the attached Macro. I would suggest that you investigate there.

Edit:

Does this only occur when in ObjectsSelect mode ?
 
Last edited:
Upvote 0
I guess the issue lies somwhere in the code of the attached Macro. I would suggest that you investigate there.

Edit:

Does this only occur when in ObjectsSelect mode ?

????? - the clicking doesn't work at all if you're NOT in the Object select mode !

I've looked in the chain of subs called by clicking on a DOT in Excel ...

when it comes to the end of the chain the unknown type of document is opened by this code - I've presented it as a Word document but in fact the type is UNKNOWN - in my tests I used Word documents:

Code:
Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
End Function

and it works nicely when tested !

Could anything in this code be changed to "FORCE" the window in front ... I think it already do that ... but maybe there was a better way ?
 
Last edited:
Upvote 0
????? - the clicking doesn't work at all if you're NOT in the Object select mode !

I've looked in the chain of subs called by clicking on a DOT in Excel ...

when it comes to the end of the chain the unknown type of document is opened by this code - I've presented it as a Word document but in fact the type is UNKNOWN - in my tests I used Word documents:

Code:
Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
End Function

and it works nicely when tested !

Could anything in this code be changed to "FORCE" the window in front ... I think it already do that ... but maybe there was a better way ?

So you are basically saying that the word doc is successfully opened but sometimes the word doc dosen't show up in the front of the screen - Is that correct ?
 
Upvote 0
So you are basically saying that the word doc is successfully opened but sometimes the word doc dosen't show up in the front of the screen - Is that correct ?

That's right !

But notice here, I used just a Word document as a test ... in fact it could be any type of document - Excel, Outlook, Word, JPG ect, ect.

I just made some tests starting from a freshly boot.

It works nicely with a SINGLE CLICK on a DOT in Excel and it opens the details for that DOT (an event) in Word and brings it to front on screen !
I tried 5-10-15 times !
Then without notice of any kind it starts NOT bringing Word to the front but shows the document as a blinking icon in the process line !
When I click on that icon Word comes in front with the right document - that's just normal Windows behavior.

FROM THEN on I HAVE TO double click on the DOTs in Excel and it works "again" ... just like before when I used single clicking ... but I now HAVE to do a double click !

Because of the changes you proposed in the Workbook the "SelectObject"-mode stays ON despite the double clicking ... and that's OK !

But I think it's a strange behavior - right ?
 
Last edited:
Upvote 0
That is indeed a strange behaviour.

The only thing I can think of to ensure the shelled application is always brought to the front is by using a CBT hook or by taking the following steps:

-Use the FindExecutable API to get the name of the actual application that was shelled/launched.
-Pass this executable & filePathname to the VB(A) Shell function. (Not the ShellExecute API)
-Get the PID from the Shell function.
-Locate the HWND with the associated PID
-Use AttachThreaInput and SetForegroundWindow APIs to force the launched application to the front.

The steps are rather involved as you can see so I think It is better to tolerate the odd behaviour you are experiencing as long as the SelectObject mode stays ON.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top