Conditional markup type and formatting in rdlc-Report - rdlc

I have a problem with formatting in one of my rdlc-reports. I'm using an ObjectDatasource with a property of type object called Value and some boolean fields like IsValueDate, IsValueInt and IsValueDouble. The value at runtime can be anything from a HTML string to a date object or an integer or double.
I want to use the report for an Ecxel-export of some data. The formatting string for the report field is something like this:
=IIf(Fields!IsValueDouble.Value, "#,##0.0########",
IIf(Fields!IsValueInt.Value, "#,##0",
IIf(Fields!IsValueDate.Value, "dd.MM.yyyy", "")
))
This works, but an HTML string is shown as plain text with all tags. My idea was to set the MarkupType with this expression:
=IIf(Not(Fields!IsValueDouble.Value) And
Not(Fields!IsValueInt.Value) And
Not(Fields!IsValueDate.Value), "HTML", "None")
This renders the HTML tags as expected but the conditional formatting of dates and numbers is ignored.
Any suggestions how to solve this?

To render HTML in RDLC report, you need to create placeholder in the cell or textBox and set MarkupType property of the placeholder as "HTML".
Here is related documentation: https://msdn.microsoft.com/en-us/library/cc645967.aspx

Related

Using formatted text from Word table to Publisher

I'm trying (and failing) to fill out a text box (TextFrame) in Publisher using a macro from content in a Word table. I'm trying to do something along the lines of:
With doc.Pages(1).shapes(1)
.GroupItems.Item(8).TextFrame.TextRange = table.Cell(2, 3).Range.FormattedText
End With
The source text from table has a bunch of font formatting that I need in the text box but it won't seem to be able to copy over the formatting and I just get the plain text. Any ideas on how to get this working properly?
Edit: It seems like TextFrame can't accept formatted text at all. Is there any way around this?
In Word TextFrame.TextRange returns a range which has a FormattedText property. The usage for that would be:
.GroupItems.Item(8).TextFrame.TextRange.FormattedText = table.Cell(2, 3).Range.FormattedText
In your code you haven't specified which property of the TextRange you want to assign the formatted text to. This means it will be assigned to the default property, Text, which is just a string and cannot contain any formatting.
Golden Rule: never rely on default properties, always specify the
property you want to use.
Given that you appear to be taking a value from Word into Publisher you should be looking at the documentation for VBA in Publisher which shows you that the TextRange object in Publisher does not have a FormattedText property, so you cannot take formatting across using this method.

Fill variables in MS-Word Document and print it in VB

I have a Microsoft-Word document with variables inside it.
These are placeholders (for example name, firstname, date).
My VB program should fill these variables inside the document (For example put date into date variable, name into name variable, and so on) and print the page afterwards.
Is there a way to do that? If yes, what keywords do i have to look up to find the correct commands?
Thanks for your help!
In addition to the possibilities Mort mentions, Word also provides
(1) Document Variables. These are a string storage inside the Word document that's not visible to nor editable by the user, so are useful for information that should be retained in the document. The content of a Document Variable can be displayed on the document surface by inserting a DocVariable field that references the Variable name. In the object model:
ActiveDocument.Variables("name").Value = "text"
The basic field code: { DocVariable "name" }
(2) Custom Document Properties. These are similar to Document Variables, but can be see and edited by the user in the Document Properties dialog box. The content can be displayed on the document surface using the DocProperty field. Their use in the object model is a bit complexer than for Document Variables as they must be explicitly created:
Dim prop As Office.DocumentProperty
Set prop = ActiveDocument.CustomDocumentProperties.Add( _
Name:="test", LinkToContent:=False, _
Type:=Office.MsoDocProperties.msoPropertyTypeString, _
value:="prop value")
Debug.Print prop.value
Other differences: A document Variable must have a value and it cannot be an empty string; a custom document property can be an empty string. You cannot "Add" a document property that already exists. The number of characters that can be stored in a document Property is limited to 255.
(3) Content Controls. You can think of these a bit like "text boxes" on the document surface. They can also be used with forms protection. If you wish, they can be linked to nodes in a Custom XML Part stored in the document. A content control can be addressed by its position in the document OR by its Title property OR by its Tag property. Multiple content controls can have the same Title and/or Tag property. For this reason, the methods that pick up content controls based on Title or Tag return an array. The code to address a content control:
Dim cc as Word.ContentControl, ccs as Word.ContentControls
Set ccs = ActiveDocument.SelectContentControlsByTitles("name")
Set cc = ccs(1)
Which of the five possibilities to use depends on all the circumstances involved in the project, including whether users should set up documents to run with your code, whether the data needs to be extracted from the document at a later point, etc.
A possible option is to use Bookmarks in your Word Doc.
Then you parse through the doc and do value substitution like this:
doc.Bookmarks.Item(bookmark_name).Range.Text = newValue
Alternatively you can search and replace in Ranges like this:
Dim doc As Word.Document = Program.LetterInstance.LetterForm.Document
Dim range As Word.Range
range = doc.Content
range.Find.Execute(FindText:=OldText, ReplaceWith:=NewText, Replace:=Word.WdReplace.wdReplaceAll)

HTML Formatting tossing #error

I am attempting to format an expression in SSRS with an HTML code and am getting #Error tossed upon report preview. My expression looks as follows:
="<b>Region: </b>" + Fields!RegionID.Value
I have also ensured that HTML - Interpret HTML tags as styles has been selected under Placeholder Properties. Has anyone experienced this behavior before?
Thanks!
In SSRS 2008 and above, you can use placeholders to achieve this.
See Formatting Text and Placeholders for more details.
To give a quick example, in a textbox, enter some text then right click on the empty space to the right of the text:
You can set the placeholder properties to display your required field in the Value property:
You now have two distinct text parts in the textbox that can be formatted independently, e.g. one bold and one normal:

Format Text to Number format in Report Builder 3.0

I am working with 4 fields in Report Builder 3.0 in which I am trying to format as a number with the corresponding comma. When I use the number format in the Text Box Properties nothing happens. When I export this report to Excel the field has to be converted to a number as it is being exported as a text field.
Do you have any suggestions as to how I can change the formatting in the report itself?
Thanks for your time!
If I pull data from Oracle using an openquery I get the same issue. To resolve:
When you have the Text Box Properties box open, select the function key by the Value.
In the expression, add "Int" at the front of the string with () on each side of expression. (This converts the value of the expression to an integer)
Ex: =Int(Fields!Count.Value)
Close the expression box after making these additions and select "Numbering" in Text Box Properties to format the text box accordingly.

Text Object in Formula Editor (Crystal Report)

How can i get the text object so that i can use it in formula editor?
Text objects cannot be read or changed using the Formula Editor within Crystal Reports. If you want dynamic content that I would suggest using a Formula instead of a Text Object.
Rather bizarrely, you are able change a Text Object value at runtime using .NET
e.g.
rptObject.ReportDefinition.ReportObjects("Text1").Text = "Some dynamic content"