How to keep shape text but not show it? - vba

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

Related

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.

MS Word ActiveX Textbox Spell Check

I am working on a MS Word form for a client where they want the ability to count the number of words, check spelling, have a character limit, and have the rest of the form locked down so that the end user cannot change anything they are not supposed to. I have attempted to convince them that word count and character limit are redundant if we have proper instructions, however, this is what they want. They also want the form to be able to "work" even if the user does not enable macros, meaning, they want it locked and a character limit first and foremost.
I know that if we just rich text content controls and put the form into a group spell check and word count word while also "locking" the remainder of the form, except user content controls do not allow for character limits and using legacy/activex controls in a grouped form locks those controls as well.
So, for now, I have settled on using the ActiveX Textbox (this is negotiable if I have a reason to use the legacy textbox) and have achieved the minimum "workability" (if that's even a word). The only way I have figured out to check the spelling is below:
Sub chkSpelling()
Activedocument.Tables(1).Rows(26).Cells(1).Range.Text = txtRole.Text
Activedocument.Tables(1).Rows(26).Cells(1).Range.checkSpelling
txtRole.Text = Activedocument.Tables(1).Rows(26).Cells(1).Range.Text
'... so on and so forth throughout each text box
End Sub
The issue is that this is not good enough for my standards. Printing the text of each textbox (up to 1700 characters) at the bottom of the screen each time I need to check the Spelling is unacceptable. Does anyone else have any ideas?
Thank you for your assistance.
Answer with help from #bibadia
Dim doc As Document
Set doc = Documents.Add(, , wdNewBlankDocument, False)
doc.Paragraphs(1).Range.Text = txtRole.Text
doc.Paragraphs(1).Range.CheckSpelling
txtRole.Text = Replace(doc.Paragraphs(1).Range.Text, Chr(13), "")
Use CreateObject to create a new word instance
Ensure .Visible = False (I think that is the default)
Create a new document in that instance.
Copy the text to be checked into that
Spell check.
Remove the document and the Word instance.
If I understand your question correctly then,
I need to check the Spelling is unacceptable. Does anyone else have any ideas?
If text boxes are named with numbers, you might be able to use loop, and save your coding lines with time.
want the form to be able to "work" even if the user does not enable macros
If user did not enable macros, he would not be able to see form (is it User Form, you want to say) and no background macro code would run. (Tested on Ms-Excel 2007), ultimately failing all.
regarding text box control on user form
yes that can be set to character limit from properties menu, and spell check can be done using your method.
Set range2 = Documents("MyDocument.doc").Sections(2).Range
range2.CheckSpelling IgnoreUpperCase:=False, _
CustomDictionary:="MyWork.Dic", _
CustomDictionary2:="MyTechnical.Dic"

What is a good way to indicate that data has changed, but not updated?

Once a record has been saved to the database, I want to have any field change color to indicate that the user has made uncommitted changes if they type into that field.
Is it best to just set the foreColor on closeField, or is it better to track each keypress, and compare it against a variable containing the previous field content?
Are you asking how to detect a text change once a process that loaded field data has been made, and new, unsaved data is being entered? You mentioned new uncommitted changes, and I am not sure what you have in mind. This means that using a closeField handler will not indicate "uncommitted changes if they type into that field"
If so, however, I would set a custom property of the field upon writing to the database, and put a simple handler in the field script
on textChanged
if me <> the lastText of me then set the foreColor of me to "blue"
end textChanged
The property is named "the lastText", and is set by whatever handler saves to the database.
set the lastText of field "yourField" to field "yourField"
The color will change to blue if anything is edited within that field. Of course, the saving handler ought as well to set the color back to black.
Here's a card level script to handle all the fields on a form. When you load the data on to the card, set each field's uOriginalText custom property to the same value as the text loaded into the field.
on closeField
# the target control for this message
put the target into tTarget
# detect case changes like 'mr jobs' to 'Mr Jobs'
set the caseSensitive to true
# compare with the original text, set when the form was loaded
if the text of tTarget <> the uOriginalText of tTarget then
# indicate the change - I've used backColor in case the field is now empty
set the backColor of tTarget to "red"
else
# clear warning background color
set the backColor of tTarget to empty
end if
end closeField
In glx2 we actually do a bit of overkill - save the md5digest of the field when you save it, then check the md5digest of the field against the saved value to see if it needs saving. Obviously you don't want to do the computation on each keypress, no matter how fast it is. Doing that on closeField is a good way to deal with it, although I seem to remember having a problem in the past with closeField not getting triggered if you click onto another app on OSX.

Checkboxes in Rdlc Report

I am creating rdlc report and i have issue that i got some bool type object fields and now i have to show checkboxes. but there is nothing i found for this solution to show checkboxes in table.
Is there anyone who know that how i can implement that thing?
Maybe you can put image there, depend on true or false, just display different pic. LOL
If checkbox is true I set Chr(254) else show unchecked checkbox using Chr(168).
Chr(254): This is decimal value for Wingdings character 254 its shows like checked check box image.
Chr(168): This is decimal value for Wingdings character 168 its shows like rectangle box like unchecked check box image.
I had a requirement that the checkboxes have a background color. I liked the simplicity of a text-based rather than image-based approach, so I used a variation of the popular Wingdings-font method: I used a small, square textbox with a thin border and the specified background color, set it to use a bold, sans-serif font, and used this expression for the text value:
=IIf(Fields!SomeBool.Value, "X", "")
If you still want a checkmark rather than an X, you can use Wingdings 2 font and this expression:
=IIf(Fields!SomeBool.Value, Chr(80), "")
In either case, you may have to adjust the font size and/or box size to keep the result square; my first take was taller than wide because it expanded vertically to accommodate the font.
Or you can set the textbox placeholder to render tags as html and then put this html in: Or you can set the Placeholder expression to support HTML and then set up the following html code:
<font face="Wingdings 2" color="green">#Html.Raw(((char)0x51).ToString())</font>
You should put in the character of the wingdings that you want.
This way, only part of the text can be wingdings.
Wingdings 2
Finally I got solution
here is the link download the project and run it.
http://uploading.com/files/2mmf34m8/Nestle%2BNew.rar/
i have developed class and then used list to set bool variable true/false. while on other hand i used image control in rdlc report To set image.
You just need to set image path which are already in image folder.
Cheers.

Programmatically set margins in report viewer control

In onw of our application, we have some reports that need very specific margins that are dependant of the printer the user have. It is used to print into preformatted paper with blanks to fill and depending of the printer, the printing is off by some margins. To make things worse, we don't actually control what printer is used because it is not an internal application.
The only solution I could think of is to let the user configure the margins somehow. I thought I could just dynamically change the report margins like I did with datasources and actual report (I have one control that is used to display every reports from my application and it works alright), but I can't seem to find that damn property to do so. There is a margin property on the report viewer but it's for the form display so it doesn't cut it.
Does anyone knows how to. What I was thinking to do is to define the margins before the user loads the report, i.e. when he clicks on the report button, I load the report, set the margins (or vice-versa is necessary) and then display it.
Before someone mention it, I know the user can, once the report is loaded, change the page setup to fit his needs, but this has two drawbacks. First one is that it is not saved each time and I need it to be 'saveable' and by users. The second one is that Report viewer seems to have some bugs when the regional setting aren't set to what it's expecting and we can't force the users to changes their setting to accommodate one application.
Edit: Forgot to mention, it this is of any uses. My reports are all local reports.
'creates a new page setting
Dim instance As New PageSettings()
'create the new margin values (left,right,top,bottom)
Dim value As New Margins(0, 0, 0, 0)
'gives your new pagesetting a value
instance.Margins = value
'report viewer now sets your margins
ReportViewer1.SetPageSettings(instance)
You can't do this directly. Try controlling your margins in the report with report parameters.
Well, I just had this similar problem; needed a report to have 0" margins, otherwise the blasted thing went from 2 pages to 6, and it split the data vertically, so the pages made no sense. I was having to set it manually in the Print Setup to print, but the end goal of this report is to be emailed to customers as a PDF, and guess what, when I set the margins manually and exported, it still split into 6 pages and bombed out. So risking everything, I tried one last supreme effort to fix this blasted thing - I opened up the .rdlc with word pad, and miracle of miracles, found 1in, etc. I set all those buggers to 0in, saved, ran my .net code (2008), opened up Print Setup, and hallelujah, there was my 0in settings. Now for the supreme test - I exported it as a PDF, went to the file, and son of a gun! Sweet. There were two crisp clean perfectly laid out pages. All was beneficent in the universe, I calmed down and let the midiclorians flow through me, and just basked in a moment so rare that it is rarely realized by some - a simple fix.
Check out the ReportPageSettings class, part of the report viewer control. Setting those values looks like it should get you what you need.
More settings;
Dim myPageSettings As New PageSettings()
myPageSettings.Margins = New Margins(0, 0, 0 , 0)
Dim paperSize As PaperSize = New PaperSize()
'ToDo: update with the PaperKind
'that your printer uses
paperSize.RawKind = PaperKind.A4
' paperSize.RawKind = System.Drawing.Printing.PaperKind.A4
myPageSettings.PaperSize = paperSize
'False for "Portrait"
'True for "Landscape"
myPageSettings.Landscape = False
'report viewer now sets your margins
ReportViewer1.SetPageSettings(myPageSettings)
this code work with me, the numbers in mm
Dim newPageSettings As New System.Drawing.Printing.PageSettings
newPageSettings.Margins = New System.Drawing.Printing.Margins(50, 100, 45, 45)
ReportViewer1.SetPageSettings(newPageSettings)
im using vb.net 2013