Format hyperlinks that span multiple lines - crystal-reports

I have an Access database (Screenshot is attached) in which the text of an editor is stored line by line in the DB (called StoryLine column). I have the problem that URLs are stored as hypertext "URL" display names. Sometimes only hyperlinks are displayed in one line and the "URL" goes over several lines and then the display name is displayed.
Thank you very much for your help and hints.
I have merged all entries (with Formula) that are assigned to the same entry (all connected texts have the same StoryID). The problem is that the formatting is completely lost.
Only the display text of the URL should be displayed, if it exists, otherwise the complete URL.
HYPERLINK "http://votetandem.org" votetandem.org
should be
voteandem.org (formatted as Hyperlink)
and
HYPERLINK enter link description here
Acquista ora i
biglietti!
should be
Acquista ora i biglietti! (formatted as Hyperlink)

If I understand your question correctly, the below should work for you;
Create a Formula and type the desired text and hyperlink using the HTML tag like:
Insert the Formula Field on the report. Right click on the "Formula Field" inserted on the report, and select "Format Field"
In the "Format Editor" window, select the tab "Paragraph". For the option "Text Interpretation", select "HTML Text"
Note that the SAP Hyperlink text displayed above is the actual hyperlink and selectable by the user. In your case, it may be a matter of just doing option 3 from above on the required fields. I don't know your current structure of the report to give you an exact answer.
Concat Strings
Create a formula with something as such. I haven't tested this so it may need some tweaking.
if {Command_Main.StoryLinesK} in ['45','46','47', '48',''49] then {Command_Main.StoryLine} & "" & {Command_Main.StoryLine}

Related

Dynamic display text MS Word Mail Merge

Is there a way to make the Hyperlink field have dynamic display text as well as dynamic URL? So far, I have the following merge tag, which is correctly pulling the URL from my CSV data source
{ HYPERLINK "{ MERGEFIELD URL}"}
I hit Alt+F9 to toggle between field source and display preview - I see I can set static text as the URL's display text, but I need to use a merge code as the display test.
The hyperlink documentation just indicates static text, I don't see a way to add a merge field. A couple of place I've seen indicate you can insert a merge tag when editing he display text, but it doesn't save correctly (on Save, it just drops the hyperlink entirely).
By default, if you insert a mailmerge field into a hyperlink field, the hyperlinks will all show the first record’s address as the 'Text to display' text. Here's how you can do get a mailmerge to display your preferred default 'Text to display' text instead:
Disregarding mergefield issues for the moment, insert a hyperlink
into the document in the normal way, choosing whatever 'Click Here'
text you want in the 'Text to display' box.
Select the inserted hyperlink and press Shift-F9 to expose its field code.
Replace everything in the field after 'HYPERLINK' with your mergefield.
Select the field and press F9 to update the display.
In Word 2007 & later, you can make the display text variable also, by following these additional steps:
Position the cursor anywhere within the display text.
Insert a mergefield pointing to whatever data field you want to use for the display text (this could even be the same field as used at step 3 above).
Delete all of the previous display text either side of your last-inserted mergefield (note that this field will likely have updated already).
Execute the merge.
After merging to a new document, use Ctrl-A, F9 to update all fields. Without this, the mergefield hover text won’t update to the correct targets.
Note 1: The above is only for merged output sent to a new document; it does not work with merges to email or print. For merges to email, see: https://support.microsoft.com/en-us/kb/912679
Note 2: Hyperlink fields modified this way are liable to cease functioning once the merge has been executed. Accordingly, it's best to save mailmerge main document before doing the merge and not re-save it afterwards. If you need to make changes to the mailmerge main document, don't make/save them after doing a merge; make/save them beforehand.

Get string within a specific string

Please excuse the stupid question, but I am an absolute freshman in Crystal Reports.
I would like to add a plaintext to Crystal Reports. The problem is, if a hyperlink has been inserted that contains a display text, it will be displayed as follows:
HYPERLINK "http://google.de/https://www.google.com/webhp?hl=de&sa=X&ved=0ahUKEwipsMvN_-vkAhWCEVAKHf3JBCIQPAgD " google.com
I just want the hyperlink to be displayed within "
The result should be https://www.google.com/webhp?hl=de&sa=X&ved=0ahUKEwipsMvN_-vkAhWCEVAKHf3JBCIQPAgD
However, it is also possible that "hyperlinks" that do not contain a hyperlink may occur.
My professor has created an Access database that contains texts and hyperlinks and I have to display the hyperlinks correctly.
Some lines of the database:
HYPERLINK "http://votetandem.org/" votetandem.org
HYPERLINK "https://app.votetandem.org/"votetandem.org
Sometimes there is a space between "URL" display text and sometimes not
Use the REPLACE() function. Hit F1 for online help.
I found a solution for my problem. I created a formular field. chr(34) is " in ASCII
If InStr({TABLE},"HYPERLINK " & chr(34)) > 0 Then
Split({TABLE},chr(34))[2]
else
{TABLE}
the URL is the second entry. The first is Hyperlink, second real URL and the third the displayed name.

Is There a Way to do a Spanish/English MailMerge?

I have an SSRS report that has Spanish and English text boxes. If the dataset row is a Spanish speaking person, an expression in each Spanish textbox shows that and hides the English textbox. These textboxes are exactly placed over each other.
My boss wants me to use SSRS to generate an Excel spreadsheet from the dataset(this is not hard) and use Word template for a mail merge. However, I am having trouble trying to figure out if I can hide all English when row is a Spanish row and vice versa. These are health clients of Spanish and English nationality.
I can do mail merges attached to a Recordset, I can do one in English, one in Spanish. I am trying to avoid this and have it all in one Mail Merge.
Areas marked in red will change to Spanish translation and/or date format. The dates are a no-brainer I can use a conditional IIF, however the formatted body I have no solution for, based on value in Field "CL_Language" which is either "Spanish" or "English".
====================================
The merge fields for dates and greeting are easy. There is no merge field for the text. And yes, only option might be for 2 separate reports with different Recordsets.
It's not clear what the actual issue is but...
Instead of hiding textboxes, which could cause problems when exporting etc., why not set a single textbox to the correct language text using an expression?
Something along the lines of
=IIF(Fields!Language.Value = "English", Fields!MyEnglishText.Value, FieldsMySpanishText.Value)
I found a solution. But it could be very difficult for the client to create. It involves hitting Ctrl + F9 which will create curly brackets {}.
Inside those curly brackets an IF statement is placed and I just pasted the whole Spanish formatted body in the true area, and the whole English body in the false area.
{IF "CL_Language" = "Spanish" "spanish body text here" "english body text here"}
Very strange syntax and you need to right click on the area to see choices like "Toggle Field Codes" (IF statement get's hidden), "Edit Field", and "Update Field". With Edit Field and Update Field you get a popup with the fields in your recordset.
If you saw the examples in my question, you can see that is some big clunky text AND . . .inside of it is a merge field that works! The Excel recordset comes already with the month name in correct language for each row.
Since it is not smart to include links that might expire, I am including the Google text I used to find this solution. Then I took a chance on a huge formatted chunk of text with a merge field inside of it.
Google this: "If Merge Field then"
Now is this a viable solution for the client versus just having a Word template for each language?
I think this is too difficult and I even duck when running it. Also, once it's working, if I look at the toggled code, the Conditional field no longer says the field name, but the value in the field, go figure.
{IF "Spanish" = "Spanish" or {IF "English" = "Spanish" instead of {IF "CL_Language" = "Spanish" or {IF "CL_Language" = "English"
Here is how to access the fields using right click. (remember, your curly brackets HAVE to be created with Control + F9).

New line return in Crystal Report

Im creating a report based on crystal report.. I'm wondering how can i return a new line like for example im a field which is bound to a a datatable where in if the number of text reach the maximum width of the field it would carry to the next line?.
Like if i had a text that is "Representation and other incidental allowances" since it exceeds the width of my field , i want to display like below:
"Representation and other
incidental allowances"
Hope someone could help me!.. Thank you!
Campagnolo_1 says you will need a formula, but I can assure you a formula is not necessary. All you need to do is place your column where you want it, give it the width you want, and right click on the field, select "Format Text", go to the tab labelled "Common" and check the box next to "Can Grow". To the right of this option, you will be able to select how many lines this field can 'grow', in other words, this is how many additional lines the field will use to display your text.
You will have to create a formula in the "Can Grow" option under "Format Field" (right-click on field). You will have to specify after how many characters you'll want the new line, so that could be tricky if your text changes.

Add Variable Hyperlink in Mail Merge in Word 2013

I'm trying to add a hyperlink to a mail merge field. So something like this:
{HYPERLINK "{MERGEFIELD "Links" }"}
So I create a field like this.
{ MERGEFIELD Links }
And the above works (it displays different links for different recipients).
However, when I go to Edit Field, and then attempt to add HYPERLINK to { MERGEFIELD Links}, Word will not allow me. Meaning that when I type HYPERLINK followed by a space, the "variable" field is gone. Instead of word displaying...
LINK
it displays...
{HYPERLINK "{MERGEFIELD "Links" }"}
even after I press "update field". So Word is not letting me enter HYPERLINK for some reason.
How do I solve this?
From the Microsoft Web Site,
On the Insert menu, click Field (under Quick Parts in later office versions).
In the Field names list, click Hyperlink,
and then click OK. The text Error! Hyperlink reference not valid
appears in the document.
Press ALT+F9 to open the { HYPERLINK \* MERGEFORMAT } field code.
Put the insertion point after HYPERLINK and then add a space.
On the Insert menu, click Field. In the Field names list, click MergeField. In the Field name text box, type the name of the data source field that contains the hyperlink, and then click OK. For example, if the name of the data source field is "Address1," the field code appears as follows: { HYPERLINK { MERGEFIELD "Address1" } \* MERGEFORMAT }
Press ALT+F9 to close the field code. You now have Error! Hyperlink reference not valid text.
Put the insertion point at some arbitrary place in the middle of the Error! Hyperlink reference not valid text, and insert the text you want to appear. If you would like a merge field, insert that from the "Insert Merge Field" option on the menu.
Delete the remaining text of Error! ... before and after the text you want to keep.
Note: If your merge field only contains an identifier, with the URL to be provided as a static part of the merge document, this can work also. On Step 5, you will need to insert the URL text as well as the MergeField, for example:
{ HYPERLINK "https://www.myurl.com/EditForm.aspx?ID={ MERGEFIELD ID }" \* MERGEFORMAT }
I also have been struggling with this. What I found to be the key is creating the document from SCRATCH and not saving it before executing the mail merge. Here are the steps I used:
open a new document and click on the step by step mail merge wizard; add your generic text.
To add the variable hyperlink go to insert>quick parts>fields
select hyperlink on the left and click okay
Use alt + F9 to see the hyperlink field code
Type “” and between them insert your merged field so that {HYPERLINK \* MERGEFORMAT} -> becomes {HYPERLINK"{MERGEFIELD"Constructed_URL"}"\*MERGEFORMAT}
Press ALT+F9 to hide the field code
Click in the text "Error! Hyperlink reference not valid" and replace with something generic like click here.
Complete the mail merge BEFORE you save the document.
Hope this helps and good luck!
Start with the process here:
http://support.microsoft.com/kb/912679
However, like user1867326 indicated, the hyperlink (which should be variable with the mail merge) is converted into a static link when the Word file is reopened.
A solution that seems to work is adding a bookmark within the hyperlink field code immediatly after the mergefield.
{ HYPERLINK { MERGEFIELD "Link" } \* MERGEFORMAT }
Click between the } and \ and go to INSERT > Bookmark, give it a name, and this seems to prevent Word from replacing the mergefield with a static hyperlink.
This answer is adapted and hopefully clarified from the clever solution described here:
Mailmerge dynamic hyperlink fields lost after save/reload of document - Word 2010
This is what worked for me for an email mail merge with variable hyperlinks that all display the same text. I am using Office 2016 Word.
Put the insertion point where you would like the link display text to be in the document.
On the Insert menu, click Quick Parts, and select Field.
In the Field Names list, click Hyperlink, and then click OK. The text Error! Hyperlink reference not valid appears in the document.
Press ALT+F9 to open the { HYPERLINK * MERGEFORMAT } field code. 5. Put the insertion point after HYPERLINK.
On the Insert menu, click Quick Parts, and select Field. In the Field Names list, click MergeField.
In the Field name text box, type the name of the data source field that contains the hyperlink, and then click OK. For example, if the name of the data source field is "Address1," the field code appears as follows: { HYPERLINK { MERGEFIELD Address1 } * MERGEFORMAT }
Press ALT+F9 to close the field code. You now have Error! Hyperlink reference not valid text.
Put the insertion point just before the period in ‘Error! Hyperlink reference not valid text.’ and delete all the text except for the period. Write in the link display text. Make sure not to delete the period (this is important).
To check that the hyperlinks are mapping, right click on the link display text and click edit hyperlink. You will see the correct link in the address field for each record.
I like to style the period text color to white so it looks invisible.
I have had limited success with the other suggestions - basically, Word is buggy in this area. There is a simple alternative - indeed the only alternative AKAIK if you want the hyperlink to vary AND the text that is displayed to vary too (not an unreasonable requirement).
Note that this only works for DOCUMENT MERGES, not for EMAIL MERGES, since it relies on processesing the output document.
The trick is to add a place marker (text that serves as an ID) wherever you want a hyperlink. Insert this via a regular mergefield. In your table of source data, you need columns
place marker, text_for_display, hyperlink
You then need to put your source data into Excel (if that isn't where you have it already) and put this formula
="Set Rng = ActiveDocument.Content: Rng.Find.Execute FindText:="""&[place marker]&""": ActiveDocument.Hyperlinks.Add Anchor:=Rng, Address:="""&[hyperlink]&""", TextToDisplay:="""&[text_for_display]&""""
into a blank column in the first row, and fill down.
You need to amend [place marker],[hyperlink] and [text_for_display] to the appropriate cell references.
If the [hyperlink] includes a query string, you may find you want to build it using a formula, based on other data in the source.
The resulting formulae can then be pasted into a macro and run on the output document.
You may then want to use the "Robbins/Mayor" macro http://www.wordbanter.com/showthread.php?t=18346 to split the generated documents.
I got this working thanks to this thread, but then it stopped working and I figured out why so I thought I'd say thanks by posting what I discovered here.
The issue is that word has a special type of curly brace. Copying the code text from this thread may not work for that reason. To get the curly braces Word wants, I used Fn + Command + F9 on my Mac running Catalina and Office 365. Apparently some Mac users may find Command + F9 works -- just test to find out. I'm sure Windows has a similar keystroke set. I found the Mac solution in this post.
Also, the syntax that works for me is: { HYPERLINK { MERGEFIELD "url" } * MERGEFORMAT } where "url" is the label of the column with the link in my Excel file. Note the position of the quotes. This differs from other posts here (I tried the other combinations) but I wouldn't be surprised if the syntax may vary across Word versions and operating systems.
To get this method to work in Mac Office 365 (Big Sur), you need to know about the Toggle Field Codes in the context menu. The shortcut above to replicate the Alt-F9 behavior will create a new field, instead of allowing you to edit the field that exists.
At these steps:
Press ALT+F9 to open the { HYPERLINK * MERGEFORMAT } field code.
OR
Press ALT+F9 to close the field code. You now have Error! Hyperlink reference not valid text.
Instead of the keyboard shortcut, right click on the error message and select Toggle Field Codes from the context menu.
Answer worked great for me with this adjustment! Thank you!