views:

565

answers:

4

I'm working on a project at work that, basically, does screen scraping. I'm using VBA to drive another system based on inputs stored in a spreadsheet. The problem I'm running into is that certain fields require a + from the number pad as a field-exit character.

I have no problem using the SendKeys function to fill in the other fields, but for the life of me, in any of the research I've done, I can't figure out how to pass that + specifically. Has anyone had to do this? I feel like there's something simple I'm not getting...

+1  A: 

Not sure about 2007, but 2003 and earlier VBA SendKeys does not support sending keypad specific keys.

I did find this utility which will do keypad keys, http://cpap.com.br/orlando/SendKeysMore.asp?IdC=New

Brettski
A: 

Do curly brackets not work?

 SendKeys I & "{+}", True
Remou
A: 

Back in another life I wrote a program called PushKeys which got around the limitations of the VB SendKeys command but was syntax compatible and had a few other features (like Sleep, numpad keys). My website that it was on isn't up anymore but fortunately someone has archived my PushKeys program here.

There are variants for VB, Delphi, C, etc. The VB one should be fairly easy to get working in VBA.

Chris Latta
A: 

I have been able to use AutoIT for some MS Office VBA projects where Keyboard or Mouse input was the only way, such as when MS Office does not expose something in the object model but it exists in the GUI.

In AutoIT script this should work to type the + key on the numeric pad:

Send("{NUMPADADD}")

You can compile an AutoIT script (*.au3) text file to create an EXE which you can run from VBA:

Dim RetVal As Variant
RetVal = Shell("YourAutoITscript.exe")

You can find AutoIT at www.autoitscript.com

Sam Russo