Create a custom information window in Word VBA - vba

Is it possible to somehow have way for the Selection.Style (and possibly other info) to always show up in a custom information window similar to the way Debug.Print prints in the immediate windows but ALWAYS visible?
I find myself struggling to quickly check a Selection.Style. MsgBox requires clicking "OK".
I have used the "Reveal Formatting" window but I would like more control over how the information displays.
Is this possible?

At least for knowing the Style at the current selection point, you don't need a custom user form. Place the StyleGalleryClassic control on the QAT or a Ribbon tab.

Related

Text selected / right click event (Outlook 2007 VBA)

I'm looking for an event that's raised when a user selects text in the preview pane of an email. E.g. you're viewing an email in the preview pane and select some text. I didn't see anything in the object reference to this effect, but the namespace is so large, it seems like there's always some object somewhere that does exactly what I need, which I'm not aware of.
Overall, what I'd like to do is see if the selected text matches a pattern and if so, insert a sub-menu in the right click menu (the one that says Copy, Who Is, Synonyms, Translate..). Help with this would be appreciated too. I believe the CommandBar is "text", but I'm unsure how to go about accessing this via name.
The Outlook object model doesn't provide anything for that.

Word add-in, custom layout

Is it possible to create a custom layout, existing ones are:
Print layout
Full Screen reading
Web layout
Outline
Draft
These can be found in the View Ribbon under the group Document Views.
My aim is to get my own layout button in either the existing View Ribbon (if it is possible to modify it) or add a new layout to my custom Ribbon.
Thanks in advance!
This answer is going to provide information on how to change standard settings of any view type control and associate these changes with certain document. This will not work with all documents and will not change the control action for whole Word Application but for one document. Operation could be repeated for few document and almost all Word button.
Important! I'm not using English version of Office application therefore some description will not match exactly to what you have. Tried and tested for Word 2010.
There are following steps to go:
Open new document- one where control should work according to your private expectations.
Go to View >> Macros >> Show list of macros
In the combo-box below middle of the Macro window choose something like Word application commands (or Word macros or similar). As a result you get list of lots of macros names.
You need to guess which of the macro is associated with ribbon control you are going to change. Use common sense and logic to find it. Sometimes two or three seems to match and possibly you will need to make a try.
A) let's try to change behaviour of draft/pending/working view ribbon control. one rounded red below:
B) find macro ViewNormal (but not ViewDraft)
C) select this macro on the list
Change back on the combo-box list to your document (while keeping your chosen macro selected)
Press Create button on the right in the macro window. You will be moved to VBA Editor to the following code:
Sub ViewNormal()
'
' ViewNormal Makro
' Zmienia widok edycji na normalny
'
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdNormalView
Else
ActiveWindow.View.Type = wdNormalView
End If
End Sub
This code is responsible for working of chosen ribbon control.
First, let's check if we can take control of ribbon button- add MsgBox "Control taken" at the end of the code, before End sub. Back to Word App and press button on the ribbon which result should be- setting of chosen view and our message box.
Now you need to change your code accordingly to set your view as you need. Use VBA for that.
Save document as .Docm and all the changes will be applied to the document each time you press chosen ribbon button.

Excel Button Growing

I'm working on a workbook in Excel 2010 that someone else created (I don't know which version they were using) with a button in it that invokes a macro. There are a lot of macros defined, so I'm right-clicking on it to find out which one it calls, but the context menu doesn't appear. Instead, when I click off, the button gets larger. I can make this happen as many times in a row as I'd like. There is another button the same worksheet that has the same context menu problem, but instead of growing, the text shrinks each time. There is another button that functions normally when I do this.
Growing buttons in Excel is a fairly common issue, with several theories about why this happens, including the use of multiple monitors or using proportional fonts. I have yet to see a definitive answer about this, but there are several workarounds that may work for you.
Delete and re-create the buttons.
Programmatically set the height and width of the buttons when the workbook is opened and when a button is clicked.
Select the button with another object or two on the sheet and group them.
Don't use them at all.
My personal choice is #4. As an alternative to buttons, I either use hyperlinks or shapes with macros assigned to them.
I think you want to enter "Design Mode" in the work book:
You should be able to right-click on the button to see what it does after that.
I have this same issue. I have two Excel workbooks with similar buttons on each. This only happens on one of them, but it happens every time I open that file.
I have found a sort of work-around. I open a blank Excel document, then I open the affected one and the buttons do not change size any more. When I open the second one, I have to drag it into the window with the already-open file. If I double-click on it, it opens in a new window and the problem remains.
I have the same issue sometimes. In my case, I could replicate it 100% on one file but it was inconsistent on an virtually identical file. I also found the size error wasn't permanent -- I could save and reopen the file to restore the button's appearance. I could also create a new window and then discard the damaged window.
For me, the button resized when I accessed the sheet's HPageBreaks collection. I was able to avoid the problem by temporarily changing the window view as follows:
ActiveWindow.View = xlPageBreakPreview
' do pagination stuff using HPageBreaks
ActiveWindow.View = xlNormalView

Is it possible to have an extension library dialog box within a repeat control?

I'm running with an 8.5.3 UP1 server and I have a need to have many dialog boxes (for confirmation purposes) for a whole bunch of "action buttons" on an xpage. The code for these dialog boxes is almost exactly the same with the exception of the confirmation message being different and the client-side JS function they are calling if the Yes button is selected.
Since I really hate repeating code over and over, I was wondering if it is at all possible to put a xe:dialog control within a repeat control and specify the message and function call from an array of values? I know I can't compute the ID of the dialog control and without that I'm not sure how I would reference the dialog to open and close it.
Any ideas? Thanks
Yes, this is possible.
Make sure that you specify that the dialog box's property for keepComponents is set to False. You don;t have to do anything special for opening or closing the dialog box, just use whatever ID you give the dialog box in you client-side action to open the dialog box in the repeat such as XSP.openDialog('#{id:myDialog}')
The XPages renderer will automatically calculate the correct ID names for you.

Programmatically set "Select objects" cursor in Excel

I'm struggling to find out how to programmatically enable the "Select objects" cursor type. I checked the object browser and expected to find a property like Application.CursorType or Application.DrawingMode.
Changing the cursor type isn't picked up in the macro recorder and I must be searching for the wrong terms as I can't find information about this anywhere.
Edit: I should've made it clear I'm not talking about the cursor appearance that can be set via Application.Cursor. Rather, I want to set the cursor into the same mode as can be set via the GUI by clicking the "Select objects" icon on the Drawing toolbar. This is the cursor that only allows selection of shapes and ignores cells, text and the formula bar.
Actually, I never knew the correct name for this cursor mode until I checked the tooltip to write this update, perhaps that'll help.
I don't quite follow why you want to do this, but you can toggle the "Select Objects" drawing mode programmatically by executing the built-in CommandBar control:
Call CommandBars("Drawing").Controls("Select Objects").Execute
And you can determine the current mode by checking its state:
If CommandBars("Drawing").Controls("Select Objects").State Then
Call Debug.Print("Select Object mode is on")
End If
Good luck!
I'm a little 'late to the party' on this one but here is the answer to 'why he wants to do this' as well as 'what he wants to do'.
'Turn ON 'Select Objects' option during initial display. While ON, cell input is prevented.
If CommandBars("Drawing").Controls("Select Objects").State = False Then
CommandBars("Drawing").Controls("Select Objects").Execute
End If
I use this in a simple timer application which has one command button and two check boxes on the 'ActiveSheet' display. By turning ON 'Select Objects', I limit the cursor input targets to these three items. Cells cannot be selected.
Cheers,
Lawrence
Would this link help?
Here's a synopsis:
Over the application, you have four choices:
xlDefault
xlWait
xlBeam
xlNorthwestArrow
You call it like:
Application.Cursor = xlDefault
Over forms, you have more choices. See the article for more.
I don't know what you mean with 'drawing mode'. However, if you want to change the appearance of your mouse cursor, the property you are looking for is Application.Cursor
You can set it to one of four predefined values: xlWait, xlNorthwestArrow, xlIBeam and xlDefault.
If you want to display other cursors, have a look this article on how to display a custom cursor in Access. Since it uses the WinAPI, the solution should work equally in Excel.
Edit:
In response to your edit: I don't think that it is possible to do what you want. The macro recorder doesn't pick it up because there is no VBA command that can do it.
Depending and what you are trying to achieve by switching to design mode, there may be other ways though.
If you want to keep the user from changing the data in your workbook, you can hide the complete Excel window using the Application.Visible property.
If you want to keep the user from selecting or changinganything, but still display the data, have a look at ActiveSheet.Protect or ActiveWorkbook.Protect, available under Tools - Protection.
If you want to move or resize some controls in your workbook, you can do that programmatically by changing the Left, Top, Height and Width property of the control, you don't need to switch to design mode in order to do this from your macro.