I'm adding an expression on VS 2017 above my report to display the name and some fields but also to display a second row with a different color and size. The font color works perfectly but for a reason the font size is the same on both rows (even when I put different size). Below is my code
="<font color='#4169e1' size='14pt'>" & "Platform by Account # " & Parameters!AccountID.Value & " " & "</font>" & "<br>" &
"<font color='red' size='2pt'>" & "Report generated on: " & Now() & "</br> </font>"
Any suggestion to fix the issue?
You just need to remove the 'pt'
="<font color='#4169e1' size='14'>" & "Platform by Account # " & Parameters!AccountID.Value & " " & "</font>" & "<br>" &
"<font color='red' size='2'>" & "Report generated on: " & Now() & "</br> </font>"
Related
I have a VBA object, aPosition.
I am trying to display information aPosition.something in an email.
My code gives me a syntax error.
strBody = "<HTML>" strBody & "<BR> & <p style='font-family:Trebuchet MS,sans-serif;font-size:22'>Equity position in sell: " & aPosition.SEC_NAME & " (" & aPosition.ISIN & ")" & " now in "& aPosition._RANKING" </p> & _
" Target Price: " & aPosition.TARGET_PRICE & "<BR>" & _
"<b><span style=""color:#C00000"">We have downgraded</span style=""color:#C00000""></b>" & aPosition.SEC_NAME & "<BR>" & " <U>Clients Impacted:</U><BR>"
You have a few problems when building your string.
First of all, you can use single quotes in your styles to eliminate the possible double-double quotes confusion.
Secondly, you seem to have strBody mixed in there twice for some reason.
Also, whatever aPosition is, you cannot have a property that starts with an underscore (aPosition._Ranking not valid), so I removed just that underscore. (so double check that part)
Try it like this:
strBody = "<HTML>" & strBody & "<BR><p style='font-family:Trebuchet MS,sans-serif;font-size:22'>Equity position in sell: " & aPosition.SEC_NAME & " (" & aPosition.ISIN & ") now in " & aPosition.RANKING & "</p>" & _
" Target Price: " & aPosition.TARGET_PRICE & "<BR>" & _
"<b><span style='color:#C00000'>We have downgraded</span style='color:#C00000'></b>" & aPosition.SEC_NAME & "<BR><U>Clients Impacted:</U><BR>"
The rule of thumb is to make sure you set a well-formed HTML markup to the HTMLBody property, for example, I see the following:
strBody = "<HTML>" strBody & "<BR>
If you want to modify the existing email body you need to paste your HTML pieces after the <body> tag and before the closing </body> tag.
I've tried several ways including making another string that acts as a space, and also " ".
StrBody2 = "<b>Downtime particulars</b>" & "<br>" & _
"Short description: " & space(10) & _
Range("External_Start_Description").Text & "<br>" & "<br>"
I want a space between "Short description" and Range("External_Start_Description").Text.
I expect this has to do with using the range function in the string.
Context: this string is later used in an email with other strings:
.HTMLBody = "<p><font color=""#112369"" face=""arial"" size=""10px"">" & StrBody & StrBody2 & RangetoHTML(rng) & StrBody3
HTML collapses runs of multiple spaces to a single space - you need to use the non-breaking space entity if you want a run of spaces.
Replace(space(10), " ", " ")
All you need to do is put quotes with a space in your concatenation like below:
StrBody2 = "<b>Downtime particulars</b>" & "<br>" & _
"Short description: " & " " & Range("External_Start_Description").Text & "<br>" & "<br>"
I'm working on an ssrs report using Report builder 2008, currently trying to concatenate using something like this but when I do so, I receive an error for the field 'lifeamount' specifying that the expression can only refer to fields within the current dataset scope. I've tried different ways to specify the dataset which is the same for all the fields but to no avail. Is this even possible?
=rtrim(First(Fields!FRSTNAME.Value,"EmployeeInfo")) & " " & rtrim(First(Fields!MIDLNAME.Value, "EmployeeInfo")) & " " & rtrim(First(Fields!LASTNAME.Value, "EmployeeInfo")) & " " & IIF((Fields!Lifeamount.Value)> 100000.00, 100000.00, Fields!lifeamount.value, "EmployeeInfo"))
SSRS expressions are case sensitive which means that your second lifeamount reference is more than likely wrong.
Try this instead:
=rtrim(First(Fields!FRSTNAME.Value,"EmployeeInfo")) & " " &
rtrim(First(Fields!MIDLNAME.Value, "EmployeeInfo")) & " " &
rtrim(First(Fields!LASTNAME.Value, "EmployeeInfo")) & " " &
IIF((Fields!Lifeamount.Value)> 100000.00, 100000.00, Fields!Lifeamount.value, "EmployeeInfo"))
If the expression is located in a cell that is within the same scope as the details you are fetching (i.e. "EmployeeInfo") then I don't think you need to specify it at all.
Also there are some brackets out of place I think. I can't test it at the moment but try this...
=rtrim(First(Fields!FRSTNAME.Value,"EmployeeInfo")) & " " &
rtrim(First(Fields!MIDLNAME.Value, "EmployeeInfo")) & " " &
rtrim(First(Fields!LASTNAME.Value, "EmployeeInfo")) & " " &
IIF((Fields!Lifeamount.Value, "EmployeeInfo")> 100000.00, 100000.00, (Fields!Lifeamount.value, "EmployeeInfo"))
I'm working on a VBA code in Excel to get input from reports and send emails.
I'm trying to avoid line breaks in my email body.
With olMail
.To = rep
.Subject = title & " - " & EndTitle
'.Recipients.Add rep
.Attachments.Add filePath & "\" & title & " - " & EndTitle & ".pdf"
.htmlBody = "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an email</u></b></BODY>" & "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an email</u></b></BODY>" _
& "<br>" & "<b>HK</b>" & "<b>" & amt & "</b>" _
& "<br>" & "Value date" & "<b>" & Trans & "</b>" & "<br>" &
initial
.Display
'.Send
End With
My email looked like this
Here is the email
Here is the email
What I want the email body to look like
Here is the email Here is the email
(on the same line)
Use this instead:
.htmlBody = "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an emailHere is an email</u></b>" _
& "<br>" & "<b>HK" & amt & "</b>" _
& "<br>" & "Value date" & "<b>" & Trans & "</b>" & "<br>" & initial & "</BODY>"
Or this, depending on which line breaks you want gone:
.htmlBody = "<BODY style=font-size:12pt;font-family:Arial><b><u>Here is an emailHere is an email</u></b>" _
& "<b>HK" & amt & "</b>" _
& "Value date" & "<b>" & Trans & "</b>" & initial & "</BODY>"
See how I encapsulated all the HTML between the opening and closing BODY tags?
I am having trouble with applying Bold on a part of a sentence for an automatically generated email.
In my VBA script:
Public strBody As String
.HtmlBody = strBody
Dim FormulaCell As Range
Dim FormulaRange As Range
For Each FormulaCell In FormulaRange.Cells
With FormulaCell
I am able to Bold a whole sentence using "< b >" & "**Text Here**" & "< /b >" &
But it seems impossible to apply the same logic to a more complex sentence, or a referenced value.
strBody = "Hello, " & vbNewLine & vbNewLine & _
"Your task : " & Cells(FormulaCell.Row, "B").Value & " with the mention: " & Cells(FormulaCell.Row, "C").Value & " is nearing its Due Date: "
What I would like to Bold in the above sentence is the value of the FormulaCells.
strBody = "Hello, " & vbNewLine & vbNewLine & _
"Your task : " & **Cells(FormulaCell.Row, "B").Value** & " with the mention: " & **Cells(FormulaCell.Row, "C")**.Value & " is nearing its Due Date: "
So it would look something like that in my email:
Hello
Your task : Eat Potatoes with the mention: Potatoes are Delicious is nearing its Due Date:
Is this something that can be done?
edited
strBody = "<p>Hello</p>, " & vbNewLine & vbNewLine & _
"<p>Your task : <b>" & Cells(FormulaCell.Row, "B").Value & _
"</b> with the mention: <b>" & Cells(FormulaCell.Row, "C").Value & _
"</b> is nearing its Due Date: </p>"