Excel/VBA - Set Focus and Scroll to Control - excel

I'm looping through the ActiveX controls on my spreadsheet to implement tab control. I have around 100 controls in my spreadsheet, so not everything fits on a single "page" (it's all in the same tab, you just have to scroll down.)
I can use Activate to set the focus to the next control. However, when I tab through the controls and pass the bottom of the viewable window, the window doesn't automatically scroll to show the control with focus.
Is there a way to get the spreadsheet to scroll so that the control that has focus is actually on the screen?

Sorceri nailed it right on the head. I used Window.ScrollRow to scroll down the page after I set the focus. The only issue is that this sets the bottom of the row to the top of the window, so it's just off screen. I was able to resolve this by specifying:
ActiveWindow.ScrollRow = row-3
Thanks!

Related

Collapsible QDockWidget when clicking on the tab

I am trying to mimic the behaviour on PyCharm, where there are docks on the edges and, if the user clicks on the tab, it exapnds and collapses the dock to increase the central widget.
I managed to put the tabs on the site, and I can subscribe to the tabBarClicked event to detect QDockWidgets, but I still need to figure out 2 problems:
How to always display a tab on each region where there is a dock (if there is more than 1 dock on that area, the tabs are automatically handled, but if there is only 1 dockwidget, no tabs are shown).
How to keep the tab if I hide the dock (for collapsing the widget).
Any ideas? This is what I got so far. As you can see, the QDockWidget on the bottom does not have a tab, but a title bar.

Word - How to stick text to the bottom of page

https://SURU.tinytake.com/sf/MTQxMTgzOV81MDc2MDI2
I want to stick some text of the bottom of the page, like on the screen, just before footer always. When there is text (from mergefield), next should be new lines. I hope screenshot make it easier to see.
You can put the text in a text box or frame with position set to "Bottom
Relative to Margin". It's the only idea I have due you don't want to use a footer.
Or you can see this article
Basically it gives three options:
Negative left indent
Margin text box
Anchor to the header
I found the solution to the problem on Microsoft's page and I hope that this page comes up for as many people as possible.
Select the text you want to stick to the bottom (or top) of the page. Under Layout tab take a look at the bottom right of the page layout section and you should see a small arrow that, when clicked on, opens a new menu. In that menu, go to layout tab and set vertical alignment to be "bottom". IMPORTANT! Make sue that the next menu option (at the bottom of that window) is set to "apply to selected sections" otherwise, you will be writing from the bottom of the page upwards.
Here is the source image that helped me. https://filestore.community.support.microsoft.com/api/images/0382c4a8-ade9-4fc4-be66-bcd2c7101479?upload=true
Here is the visual representation:
Note that the person who took the screenshot set the last setting to whole document, not just selected sections.
If selected sections option isn't available, make sure you selected a text before opening the menu.
Hope this helps!

how to prevent vertical scroll bar in an owner drawn combo box when only 3 items exists?

I sub-classed a combo-box control to make text vertically centred. Issue here is I am getting a vertical scroll bar when only 3 or 4 items exists in the combo-box that too when I expand the control for the first time, where a vertical scroll is not required.
Control property had been set as follows.
COMBOBOX IDC_COMBOBOX,28,45,205,65,CBS_DROPDOWNLIST | CBS_OWNERDRAWNFIXED | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP.
When I removed WS_VSCROLL vertical scroll bar is not coming. But if I remove this property I will not get a scroll bar when too many items exists in the combobox, where actually a scroll is required.
Please find the below Images for your reference how the control is behaving.
Run the MFC application.
Expand the combobox.
Again try expanding the combo box issue is not reproducing. It's happening only
for the very first time when expand the control.
I could not figure out why this issue is happening. I tried removing the existing control and again I tried adding new controls expecting whether it could bring any change in the behaviour but no luck.
Item height is set to 30 as below.
m_ComboBox.SetItemHeight(-1, 30);
And I had two combobox controls in my properysheet application as shown in the image.
Any help is appreciated.

How remove focus to the list box?

I am having a lisbox where I had set it's property "Selection" to "None".This lisbox is being used in a propertysheet.When I navigate on to the page where list box control is present,here initially when I click on the listbox no selection is happening,this is excepted result.But my only concern is in the lisbox page itself when I use "tab" usually the rectangular dotted line is coming on the Back,Next and Cancel buttons(this is expected),but at the same time after playing with tab around on those buttons,if I had a mouse click on the list box I am getting a rectangular selection on the Item's in the listbox(this is not expected),No selection has to occur.
I even set the "Tab shot" property of the list box to FALSE.
Can anyone please let me know how can I avoid that rectangular selection on the listbox items,even after using "tab" and having a mouse click on the lisbox that rectangular selection should not happen.
Must be a glitch... If you want to prohibit selections on your listbox without disabling it, what happens if you try
void CMyPropertyPage::OnSelchangeList()
{
m_list.SetCurSel(-1)
}

MFC Ribbon CEdit Textbox Allignment in Panel

I am trying to align two text boxes with two buttons in a panel, and I am unable to find anything about how to force positioning inside the MFC Ribbon Panels.
Here is a picture of what I have currently.
http://i.imgur.com/ofD0b.jpg (Sorry wont let me post images yet, have to link.)
The Change View Date box has the box associated with it sitting below it and the change system date box is up in the top right in the second "column" of controls. I would like to fix this so the Box with the spin controls sits next to the CHange View Date and the box without the controls sits next to Change System Date.
Thoughts? Thanks!
I think yow cannot do it.
What you can do is to put a Ribbon Separator after the Box with the spin controls and then set the property 'Center Column Vertically' on the Panel.
Hope it can help.

Resources