How to replace a selected text in synedit? - delphi-2009

I'm doing a custom text editor in Delphi with SynEdit and i'm at a loss with a simple need:
I want to have a popup button that, when clicked, replace the selected text with an uppercase version of that text. I think i have to use SelStart y SelEnd, but i'm not sure how can i do it.
I went into google and find mentions of a "La biblia de SynEdit" but the links were dead, so i ended here, hoping for a helpful soul who can answer my questions or has a copy of that bible.

Set SelStart to the beginning of the text, and SelLength to the length of that text (or, alternatatively, set SelEnd to the end of the text), and then assign your new text using SelText. This is the same way it works in the VCL.TRichEdit component.
SynEdit1.SelStart := 1;
SynEdit1.SelLength := Length(NewText);
SynEdit1.SelText := NewText;

Related

MS Word, how to change formatting of entire paragraphs automatically in whole document?

I have a 20-page word document punctuated with descriptive notes throughout, like this:
3 Input Data Requirements
Some requirement text.
NOTE: This is a descriptive note about the requirement, which is the paragraph that I would like to use find-and-replace or a VBA script to select automatically and change the formatting to italicized. The notes invariably end in a carriage-return: ΒΆ.
If it was just a text document, not MS-Word, I would just use a regex in a code editor like sublime to wrap it with <I>...</I> or something along those lines.
Preferably, is there a way to do this in Word's "advanced" find-and-replace feature? Or if not, what's the best way to do it in VBA?
I've tried using a search string like this in find-and-replace: NOTE: *[a-z0-9,. A-Z)(-]{1,255}^l but the line-break part doesn't seem to work, and the 255 char max isn't enough for many of the paragraphs.
EDIT: Another slightly important detail: The doc is automatically generated from another piece of software as a .RTF, which I promptly converted to .docx.
Attempt #2: Use Notepad++ to find and replace using regex. Remove quotes.
Find: "( NOTE: .*?)\r"
Replace with: " \i \1 \i0 \r "
//OLD
Sure is. No VBA or fancy tricks needed.
CTRL + H to bring up the replace dialog.
Click "More".
Select "Font" in the drop down menu called "Format".
Click italics.
Enter find and replace text as the same thing. Make sure you set this up right so that you don't accidentally replace substrings (e.g. goal to replace all " test " with " nice ", testing -> niceing).
Should work. If you need to alter entire paragraphs, consistently, then you probably should have used the styles on those paragraphs to begin with. That way, you can change all of them at once by updating the style itself.
You can use Advance Find, yes. Find Next and then Replace makes the selection Italic.

How to delete the last return in a PowerPoint field?

I have created a function that allows a user to import one or more text files into a field in PowerPoint. This works really well. The user clicks in the field, clicks the button on the custom menu, selects the files from a list and in they go. The problem I have is that I have to put two returns between each imported text, which means there are two left on the end.
This is the usual result to delete a paragraph I have found:
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=27, Length:=1).Select
ActiveWindow.Selection.TextRange.Text = ""
This suggests I would have to calculate the last position int he selected field to be able to delete it.
Could anyone give me an idea of how I would go about this?
This solution is a bit easier (not tested):
dim tmpTXT as string
tmpTXT = ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Text
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Text = Left(tmpTXT, len(tmpTXT) -1)
You could do something similar earlier, before you write text to your shape which would be better.

Word 2003 vba cannot change bookmark font

The following code does not work
objDoc.Bookmarks("SomeBookMark").Range.Font.Bold = True
objDoc.Bookmarks("SomeBookMark").Range.Text = GetSomeText()
objDoc.Bookmarks("SomeBookMark").Range.Font.Bold = True
When I run the code the text that is retrieved by GetSomeText() still has the default font.
Why don't you just style the bookmarks?
I searched for this in the past and also didn't find a proper solution back then.
However, since a bookmark represents a fixed field in a text template, usually the format shouldn't change so easily.
I'm sorry to put this in the reply field, but I can't find the "comment" button :-s

Crystal Reports Cutting Off Text in PDF

I found this post on Crystal Reports Cutting Off Text in PDF, but it didn't solve my problem.
I have a Crystal Report that contains a field within a text object (to control line spacing) and has "can grow" selected. When I export the Crystal Report to a PDF there are instances when the text is cut off.
In this example the text is being cut off on the right side, but in some cases, when the text consists of many lines, the bottom part of the last line will be partially cut off.
I am using Crystal Reports that is bundled with Visual Studio 2008. The text area has "can grow" checked, the font is set to Helvetica LT Condensed, bold 14, and the line spacing is set to 0.75 times normal.
Anyone have any thoughts on how can I fix this?
I have run into this as well - Crystal seems a little confused about where the text box borders are. I suggest adding a small right indent to the text box (right click on the text box, select 'Format Object', select the 'Paragraph' tab, and enter small numbers (maybe .2 or so) into the Right text box. This should help with the right margin.
As for the bottom cut-off, there is no margin that you can add. Can you add a line break to the end of your text as it comes from the db? Or, you could try a formula field to add the line break:
{table_name.field_name} + chr(13) + chr(10)
I think I've found out the problem. The bounding subreport width was smaller than the width of the field object. Adjusting it's width fixed the truncation occurring on the right-hand side.
On a side note, text being truncated on the bottom seems to be a result of adjusting the line-spacing too small. if you set the line spacing as a multiple of the original text point size and make it too small, the bottom part of the line is truncated. I changed this to "exact" and entered a specific point size (e.g line spacing of 18 pt. for my 16 pt. text) and this seemed to solve the problem. If the line spacing is too small it seems that Crystal masks off the bottom part of the text.
Right click on the text field
Select Common Tab
In the Horizontal Alignment section I changed it to "Justified".
This adjusted the text to span properly and not cut off prematurely when using Can Grow.
I tried this and it solved this issue.
Try to do following :
Text Object > Right Click > Format Text > Border Tab
Change Line Style : Right/Left/Top/Bottom as single and change color to White.
I experienced this problem when I updated a Stored procedure. I changed the Description field that I was pulling onto the report from a VARCHAR(100) to a VARCHAR(150) inline with a requested change. The Crystal report in preview mode had stored old limit of 100 characters and was truncating the label. This was rectified when I verified the database again.
Database Tab -> Verify Database
I too discovered this too. Only happened in HTML view. I did a few things which for 3 blocks I needed to do different and tried numerous scenarios to choose the best to go with.
- Format text from left justufied to justified
- Grip the right edge of the text box and pulled it in a tick from the right margin
- Switched the font from Times New Roman to another (wierd)
- Exporting from BI LP as a CR RPT and exported from the CR 2013 client to PDF
- Change font size - We had an "and / or" midline and changed it to "and/or"
We went with the justified alignment since it was close to a full line and didn't look different than original.
Lots of wierd workarounds that rectified it. To me, it's indicating a system upgrade glitch in the report.
Hope what I found helps others.
If you tried all the methods and still not working, you can try the following:
Local StringVar inString := 'Your text string here.......';
Local NumberVar strLen := Length (inString);
Local StringVar result := "";
Local NumberVar maxLen := 45; // adjust the length of text per line
Local NumberVar idx := 0;
Local NumberVar proceed := 0;
While strLen > maxLen Do
(
proceed := 1;
idx := maxLen;
While (mid(inString,idx,1) <> " " and idx > 1) Do
(
idx := idx -1;
);
if (idx = 1) then
result := result + mid(inString,1,maxlen) + chr(10)
else
(
result := result + mid(inString, 1, idx-1)+ chr(10);
strLen := strLen-idx;
inString := mid(inString, idx+1, strLen)
)
);
if proceed = 1 then
(
result := result + inString
)
else
(
result := inString
);
result
In one environment with Crystal Reports it was a help for us to set the registry key: ForceLargerFonts = 0
How to find?
For 64 bit version of MS Windows:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\Export\PDF
For 32 bit version of MS Windows:
HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\Export\PDF
Please see also the following solution at
https://apps.support.sap.com/sap/support/knowledge/public/en/0001835763
This is a difficult problem that you have to attack from 3 different fronts:
Software Hot Fix
Default Printer
Form Authoring
Software Hot Fix: You'll need to download the CRRuntime that includes Hot Fix 20. This Hot Fix addresses truncation problems when making a PDF. You can find it at http://downloads.businessobjects.com/akdlm/crnetruntime/clickonce/CRRuntime_64bit_13_0_20.msi
Default Printer: The printer you use when authoring a report must match a printer where you are rendering a report. On our servers, there are no printers installed except the Microsoft XPS Document Writer. Be sure to select that as you default printer when writing the report.
Form Authoring: When you add a database field to your report, don't drag it from the field explorer onto the design surface. First insert a text object onto the design surface. When you've positioned and resized the Text Object the way you like it, drag the database field onto the Text Object. You'll see the name of the database item in curly braces appear in the Text Object. For whatever reason, the database field will wrap better when it is enclosed by a Text Object.
This got me literally stressed for a whole night!!
What worked for me was this:
if you are using crystal reports with dataset (linked to a dataset),most likely you changed the length of the field in the database. so if the length was 10 and you adjust to 20 for instance, no matter what you do, the report is reading the "Old" dataset with the field of length 10 characters and truncating it at 10 (I don't know why it did that)...believe it or not I just copied the query from my "Old" dataset,created a new dataset and VOILA!!! it worked like charm...

Formatting text from Mulitline text box in word with VBA

I'm putting together a template in Word, using a form for the user to fill in to then populate some of the document.
The bit I'm currently stuck on is at the end of the document, where the cc's are listed.
The form has a multiline text box into which the user puts in their cc's, one per line.
I then want to add to the end of the document the contents of the text box, but in the right format. Specifically, it should look like:
cc: First CC contact
Second CC contact
so on and so forth
I attempted to do this using 2 bookmarks, so my code currently is:
' If 'CC' box has content, add it
If doc_CC.TextLength > 0 Then
.Bookmarks("CC").Range.Text = vbCr + "cc:"
.Bookmarks("CCs").Range.Paragraphs.Indent
.Bookmarks("CCs").Range.Text = doc_CC + vbCr
End If
However, when this is run, on the page it looks like:
cc: first contact
second contact
and so on
Realise that the 2 bookmark method is a bit messy but it seemed like a good idea at the time - obviously this is not the case! Have done some searching for a way to do it with Split but am not making much progress down this path - suspect I'm googling for the wrong thing.
How do I do this so that the formatting is as desired? Any help is greatly appreciated.
Try inserting a tab character? + Chr(9) or even + vbTab may work.
Have found a work around which, while doesn't answer the actual question of how to do it, does produce a result to the same effect.
Have used a 2 column table without no lines instead with contents of a1 being "cc:" and contents of a2 being whatever was entered into the multiline text box. If there is nothing in the text box, then the table is deleted.
I'll keep on eye on this question though so if some one does have the proper answer I can mark it accordingly.
Another possibility would be to format the cc paragraph with a hanging indent (like is used for bullets or numbering). Use a newline character - Chr(11) - instead of vbcr to separate each entry. The text should all line up,then...