Lock OfficeRibonLabel size - vsto

I have an Excel VSTO plug-in which displays error messages in a RibbonLabel.
Changing the label text causes it to resize which causes its containing RibbonGroup to resize which moves the last group separator right and left with each message. This looks very annoying.
Is there a way to freeze Ribbon control size or, alternatively, any other way to display immediately visible error message which will not block the document itself (i.e. NOT message box)?

You could write the label to the status bar.
excelApp.StatusBar = String.Format("Processing line {0} on {1}.",rows,rowNum);

Related

How to keep shape text but not show it?

My firm uses MS Azure Information Protection to attach privacy labels to documents.
When we send customer letters, the label shouldn't be visible. We select the Shape object the label is stored in, and set text fill to 'no fill', so the letter does not show the label. The but document still has the privacy setting embedded for internal retention.
Due to volumes this needs to be automated.
I cannot see anything in Shapes.TextFrame.TextRange that duplicates the 'no fill'.
You're looking for
ActiveDocument.Shapes(1).TextFrame.TextRange.Font.Fill.ForeColor
but I'm not aware of a "no fill" property for that. You could make the text the same color as it's background. But instead, try making the text hidden:
ActiveDocument.Shapes(1).TextFrame.TextRange.Font.Hidden = True

How to extend dialogue dynamically to add error msg in vb.net windows form application

I have aLogin dialogue like the image below and I am showing the error messages on top of the dialogue.
As you can see I am leaving a rather big empty area on top of the dialogue for these messages(it can be up to 5 lines of text) which does not look good. I would like to remove the empty space on top and add the space in run time when there is an error line added.
I know that it is possible to move each element of the Dialogue down when a new error line is added(e.g. button1.Left += 200, for each element in dialogue), but is there an easier and more practical way to do it?

How do I highlight the content of a TextBox/RefEdit control and set focus simultaneously?

I'd like to highlight the content of a TextBox/RefEdit control and set focus simultaneously when there is any invalid entry and after prompting a message box warning the error so that user knows where to fix the error. You can try Data>Analysis>DataAnalysis>Sampling and enter some invalid range/data, then you will be redirected to the invalid entry. The invalid entry is highlighted as well as with focus set (you can see a flickering cursor).
I tried to emulate this and I used,
aControl.SetFocus
aControlt.SelStart = 0
aControl.SelLength = Len(aControl.Text)
While the content inside the control is highlighted in blue, there's no flickering cursor as if I did not set focus of the control. How can I fix this? Or what's the best way to guide the user to the place where the invalid entry exists?
What if user inputs more than one invalid entries. How do you plan them all selected and setfocused at the same time.
There is no need to complicate things for you and for user. What you can do is create invisible labels with the right message you want to deliver to user, preferably in red color, and place them below each TextBox/RefEdit. Make them visible with Label1.Visible = Truewithin your conditional check.

VB.NET Changing Colors for each line in a error message

Hi I created an error message that contains each value of whether or not is was a pass or fail. I would like each entry to change color based on Passed = green and pail = red.
Example:
Fare: Passed
Name: Passed
Date: Failed
Address: Failed
Age: Passed
This gets displayed in an output message box, currently
msgBox(errorMessage)
When this gets displayed I like the fails background to be red and the passed to have a
green background.
Currently I am still considered new to VB.Net I know how to do for mouse hovers and mouseleaves. I am assuming I need to make an event similar to those.
Thank you For your help.
You're not going to do that with MsgBox or MessageBox.Show, which MsgBox calls internally. You're going to have to create your own form and then either add one Label for each line, in which case you can set the ForeColor for each one, or else draw the text yourself using GDI+. If you do go the Label route, you'll probably want to use a TableLayoutPanel or FlowLayoutPanel to keep them aligned correctly.

How to change the Contents of a msg box

I have a form for creating a record, I also have a button on the top of the form for to return to a form called home. When the form is being viewed and half the information is put in and the home button is clicked an error pops up saying " you cannot add or change a record beacasue a related record is required in a table "Elements"." How do I Change what the content of the error message is ?
You can put checks in your button_click sub to circumvent -- check to make sure all fields are filled in, and if not, display your own message box followed by
Exit Sub
That will short circuit the rest of the method so you should not get the standard message.
Here is a resource on error-handling in VBA: http://allenbrowne.com/ser-23a.html
I'm not sure, however, if you can create a handler in VBA for standard program error messages.