0

At work we have an add-in with some ribbon buttons for us to use. The add-in is password protected and we cannot even see what those ribbon buttons are calling. So there is no way for me that I know of to see any names of any subroutines or macros within the add-in.

I was wondering if it was possible to code something that would mimic the clicking of the buttons? I need something that can interact with these buttons. I am hoping this is possible as later on I would also like to code something that can click links on webpages and buttons on other programs.

Horace

Community
  • 1
  • 1
Horace
  • 252
  • 2
  • 4
  • 15

2 Answers2

1

To use webpages, you should use Selenium.

Simulating mouse clicks is never a great solution. What if the interface changes, or you try to use it on a different screen with different resolution, where everything is not where it used to be?

Anyway, you can either send mouse click using VBA:

Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10

Private Sub SingleClick()
  SetCursorPos 100, 100 'x and y position
  mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub

Or you can use an external program like AutoIt.

But it would be way way better to talk to the autohours of the plugin, and ask for a programmable interface. That would be a lot more robust.

vacip
  • 5,246
  • 2
  • 26
  • 54
  • Yes asking for a programmable interface is something I am pushing in parallel. – Horace Dec 14 '16 at 10:28
  • I was hoping there is a way to recognize text and links and therefore it will know where to click. For the interface stuff, changes will come very slow, and perhaps with some image recognition I can recognize the buttons or at least recognize when the interface changes and abort code – Horace Dec 14 '16 at 10:29
1

You can try to replace pass to addin (if this addin was created with excel, but looks like it was) with Hex Editor, so you need only Hex Editor (e.g. Xvi32).

Ok, let's try it:

  1. Rename your add-in file to zip (filename.xlam -> filename.xlam.zip)
  2. Extract vbaProject.bin from that archive
  3. Open vbaProject.bin with Hex Editor and find string "DPB" picture
  4. Replace DPB with DPx, save file and Drop that bastard back into archive with replace.
  5. Rename file back to .xlam (filename.xlam.zip -> filename.xlam)
  6. Open it, some errors would pop-up, but dont worry, we are hackers, just accept it and move on!
  7. Right click on addon in VBE editor, go to properties -> protection
  8. Set new password, save add-in and re-open it to see no errors here.

Cheers (:

CommonSense
  • 4,232
  • 2
  • 14
  • 38
  • Or possible rename to zip, look at the custom ribbon that's been put in place at the action calls, then you can reference the addin and make the same calls. – Nathan_Sav Dec 14 '16 at 10:11
  • In the zip there is only my xla file, no bin file from the archive. – Horace Dec 14 '16 at 10:26
  • In the link CommonSense gave, I would need an old computer with XP and Excel 07, two things that I do not have – Horace Dec 14 '16 at 10:28
  • @user3759627 Eh, you dont need a rusty computer to do this, but if your add-in is .xla file - bad news for you. Renaming to .zip works well with .xlam add-ins, because they're .zip archives with .xml documents inside. .xla add-ins is old format and structure of this file is secret to me, sorry. – CommonSense Dec 14 '16 at 11:04
  • 1
    @user3759627, but if you interested in source code, you can easy convert .xla to .xlam. Just open .xla file in excel, open immediate window and exec line "thisworkbook.isaddin = false" withnout quotes, then you can save your addin as .xlam and try my answer again. – CommonSense Dec 14 '16 at 11:19
  • oh ok you mean to change the extension, will try right now after i take a dump – Horace Dec 14 '16 at 11:28
  • @CommonSense You are more than common sense. That worked awesomely. Thanks!! – Horace Dec 14 '16 at 13:33