I want to make an ajax like search in excel 2003 vba. I found a script that can catch button presses.Here -> Is there any event that fires when keys are pressed when editing a cell?
The problem is how to get the text you are currently editing? It will be put in the Cell.Value only after you hit enter.
I was thinking you know what the cell.Value was when you started editing and you can apply the button pressies to it. This would work till you don't use the mouse to change the cursor position.
If you're able to detect the key-presses, you could just build up a string of each character pressed until the enter key is pressed, although you might have to handle special keys like line-breaks, arrow-keys, insert, delete and backspace, and Cut/Copy/Paste.
Related
I'm using VBA + Selenium to export data.
Work sequence is as below
enter specific numbers input box
Click button
Sel.FindElementByXPath("//tbody/tr[2]/td[6]/button[1]/em[1]").Click
Export data
Above works should be in loop until the end.
Problem is that sometimes number of click buttons can be different.
How can i make VBA to click the button until the end?
FYI, I found the rule that "tr[2]" changes like first one is tr[2] and second one is tr[3].
//tbody/tr[2]/td[6]/button[1]/em[1]
Scenario
I have an excel worksheet where I am using a certain cell (say C3) as a button functionality: Whenever the cell is selected (SelectionChange), a certain function is executed.
In order to be able to click the cell several times in a row, after performing the desired functionality I am setting the selection back to a neutral cell (say A1). This way, C3 can be selected again and the function can run again.
Problem
I would like to click the button cell (C3) several times in a row in quick succession. However, when I click it twice shortly in a row (double-click), it actually enters into edit mode for the neutral cell (A1).
I am aware of the option Cancel = True in the BeforeDoubleClick event handler. However, this doesn't work for me because it cancels the entire event altogether: With Cancel = True the second click will simply be cancelled altogether and my desired function simply won't run.
Question
Any smart ideas on how to prevent the double click while at the same time still interpreting the second click as just a normal single click?
Just expanding my comment to an answer:
Can you disable Allow editing directly in cells on File > Options > Advanced > Editing Options? Although this is a non-programming approach, it may be the simplest solution to your problem.
You could try cell security. Do not allow locked cells to be selected and use VBA to turn security on or off.
The cell could be unlocked by default and a transparent label could lock the cell on mouse rollover.
I have a few different userforms in Excel 2007 right now and was wondering if I could add a "?" button next to the close symbol in the userform.
Alternatively, is there a way to display some text when I hover over a specific label
The form property "WhatsThisButton" displays the question mark icon next to the close button, but this does nothing without creating an actual help file and assigning it to your form, this is not an easy thing to do. Far easier is to display text as you have described, each control has a "controlTipText" property that will display whatever text you enter in there, when your user hovers their mouse over the control
I have an excel toolbar created by VBA macros. When cell is in edit mode, I'm unable to perform any toolbar actions, the event itself is not getting triggered. Button events are getting triggered when we come out of that editing cell.
Is there any way to handle this? I want to allow users to click on buttons even when cell is in editing mode.
Thanks.
VBA will never run if a cell is in edit mode. If you are typing inside a cell, VBA is halted. Infact, if you press ALT + F11 and bring up the VBA editor window, and then go to edit a cell in Excel, you'll find you cant ALT + TAB back to the editor, it's gone. You cant even get back to the editor whilst you are in edit mode. (Obviously when you click outside Excel, the cell is no longer in edit mode, so you can select it from the windows tray)
You may have to use a form to allow users to edit cells, this way VBA will still run whilst the form text box is being typed in. Then submit it to the cell when the text box is complete
I have a .doc with a command button (cmdStart) which opens a form.
After populating the form I click a button to close the form and populate the .doc.
I want to hide the initial cmdStart on the .doc as well when the form closes,
Ive tries document.shapes(1).visible=false and cmdStart.visible=false but none seems to work.
Any ideas?
thanks
(ps I cant just opne the form from the autonew, I need the cmdStart visible to begin with)
You have several options to deal with that. However, you won't be able to hide your command button but you will be able to remove it.
Removing a command button can be done by the following code:
Private Sub CommandButton1_Click()
CommandButton1.Select
Selection.Delete
End Sub
(Note that usually you would be able to hide text in Word by setting the font hidden, e.g. by calling Selection.Font.Hidden. However, this does not affect controls.)
If you deleted the button and you need it later on again you will have to re-create it. In that case it might be a good idea to mark the position of the button with a bookmark.
Another option would be to use a MACRO button field. Such a field can be inserted from the Insert Field dialog and can be used to launch a macro.
If you really wanted to "hide" the button, you could set the Height and Width to 0.75 and it's virtually gone. Then resize back to "show". I've also seen people put them inside tags and hide the tag. Hope this helps