Global Send Keys Issue - blueprism

I have an object which should highlight all text in a Word document and then press CTRL SHIFT F9 to remove all links. All the text highlights but the links remain afterwards?
I am global mouse clicking the page and then global sending "^+{F9}"

Managed to get this to work by extending the Word VBO Object.
Code used
Dim d As Object = GetDocument(handle,document_name)
d.Select
With d.Fields
.Update
.Unlink
End With
d = Nothing

Related

How to resize a graphic object in the LINK field?

After a Paste special linking of a range of cells from Excel to Word (2013) the field looks like this:
{ LINK Excel.SheetMacroEnabled.12 D:\\20181228\\SC.xlsm Sheet1!R10C1:R10C20" \a \p }
If you click on the object with the right button, select "Format object" and then click on "?", the Format AutoShape reference article opens.
However, ActiveDocument.Shapes.SelectAll does not detect this object.
This code also does not work, although the error message says that this component is available for pictures and OLE objects:
With ActiveDocument.Shapes(1).PictureFormat
.ColorType = msoPictureGrayScale
.CropBottom = 18
End With
What is this object?
I cannot find it in Object model (Word).
How to access it through VBA?
I want to programmatically resize a group of such objects to 90% of the original.
Upd. #Cindy Meister suggested where to dig, thanks.
I wrote the code, it seems to work fine:
Sub ResizeImages()
Dim img As Long
With ActiveDocument
For img = 1 To .InlineShapes.Count
With .InlineShapes(img)
.ScaleHeight = 90
.ScaleWidth = 90
End With
Next img
End With
End Sub
A Link field must be an InlineShape - it can't be a Shape, not if you can display the field using Alt+F9. Since Shape objects have text wrap formatting any field codes associated with them (usually none) aren't accessible.
Therefore, any object that's displayed via a Link field should be available via the InlineShape object model.
For example, the following code loops the fields in the document and, if they're link fields with an Excel source and contain an InlineShape, the InlineShape's dimensions are scaled:
Dim fld as Word.Field
For Each fld In ActiveDocument.Fields
If fld.Type = wdFieldLink
If fld.Result.InlineShapes.Count > 1 And _
InStr(fld.OLEFormat.ClassType, "Excel") Then
Set ils = fld.Result.InlineShapes(1)
ils.ScaleWidth = 90
ils.ScaleHeight = 90
End If
End If
Next

Edit richtext field and paste it edited in another richtext field

I'm heaving problems with a specific task on Lotus Notes. I have to copy a rich text field edit it and paste inside another rich text field. But when I edit the content the text style disappears. I've tried to use this solution:
http://www.bobzblog.com/tuxedoguy.nsf/dx/geek-o-terica-15-easy-conversion-of-notes-documents-to-mime-format-part-1
to copy the html and then edit the content. But I got another problem with this:
java.lang.ClassCastException: lotus.domino.local.Item incompatible with lotus.domino.RichTextItem
Can anyone help me with my task?
Thank you.
You don't specify how you want to edit the richtext data. But if you by "edit" mean "programatically make changes to", you can do that in regular Lotusscript using the NotesRichTextItem class.
I wrote a mail-merge class a while back, and it is replacing content in a rich text field with other values, keeping the formatting. If you look at the code you can probably figure it out.
http://blog.texasswede.com/code-mail-mergeform-letters-in-lotuscript/
The relevant code is here:
Public Function MergedRichText() As NotesRichTextItem
Dim range As NotesRichTextRange
Dim cnt As Integer
Set tempbody = sourcefield
Set range = tempbody.CreateRange
Forall p In placeholder
Call p.ProcessPlaceHolder(sourcedoc, maindoc)
If p.text = "" Then
p.text = " -- "
End If
cnt = range.FindAndReplace(p.placeholderstring, p.text, 1+4+8+16)
End Forall
Call tempbody.Compact
Call tempbody.Update
Set targetfield = tempbody
Set MergedRichText = tempbody
End Function

How can I delete an object which is the subject of a loop?

The problem I have is that the user is copying from one content control and pasting it into another accidentally. When extracting the data from this form, it then picks up that extra CC and therefore the value twice over.
When pulling the data I'm trying to see if a CC has a ParentCC and then delete it, but I keep getting
Run time error 5825: Object has been deleted.
I can understand why but I'm unsure as to how get around it, nothing I've searched seems to work.
'With Word document Statement precedes this
For Each CCtrl In .ContentControls
CCtrlText = CCtrl.Range.Text
If Not CCtrl.ParentContentControl Is Nothing Then
CCtrl.ParentContentControl.Range.Text = CCtrlText
CCtrl.Delete
End If
Next
How can I remove this content control which is duplicated inside the other and retain the input information?
So after some messing around and looking into how the local variables properties changed as a stepped through the code I have found that the line:
CCtrl.ParentContentControl.Range.Text = CCtrlText
Was in effect replacing the Content Control (CC) in it's ParentCC range property with the input text, and therefore deleting the duplicated CC.
CCtrl.Delete was trying to delete an object that had already been deleted and that swhy it was throwing an error.
I think with a foreach loop you can't alter the contents of the list/array without impacting the function of the loop. If you instead use the indexers, it should allow you to alter the collection, since you are not impacting the loop (number to number):
Dim i As Integer
Dim c As ContentControl
For i = 1 To d.ContentControls.Count
Set c = d.ContentControls(i)
c.Delete
Next i

Insert cell content to word bookmarks doesnt delete the bookmark signs

I have a Worddocument with bookmarks. From Excel I write cell content to the places where I set the bookmarks.
My problem: You can still see the bookmarks.
What I tried:
First I used a placehoder bookmark with
.item("Name1").Range.InsertAfter Rep.NName1
Second I used an enclosing bookmark with
.item("Name1").Range.InsertAfter Rep.NName1
and
.item("Name1").Range.InsertBefore Rep.NName1
I still cannot get rid of the bookmarks.
All I could do is using the sledgehammer approach and delete them but I think there should be a way to replace them during the insert.
Source
If you want to overwrite the bookmark (ie replace any text contained within the bookmark and delete the bookmark itself), you can just set the Text property of the Bookmark's range:
.Item("Bookmark1").Range.Text = "Some new text"
If you want to replace the content of the existing bookmark but identify the new text with the bookmark, you'll need to replace the text then mark the new text as the bookmark:
Dim bmRange As Range
Set bmRange = .Item("Bookmark2").Range
bmRange.Text = "Some new text"
.Add Name:="Bookmark2", Range:=bmRange

How to insert text and possible rich text as well at the current position of the cursor in a rich text field in Lotus Script?

At first, there's a rich text field in the form that has a text inputted already (for this scenario - "hello world"). I have placed the cursor just after the letter "o" from "hello". I have a button that will open up a dialog box with one text field and I was wondering how would you be able to insert the text from that field from the dialog box at the current position of the cursor in the rich text field.
So far the code I have is:
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim docFill As New notesdocument(db)
Call workspace.DialogBox _
( "Test", True, True, False, False, _
False, False, "Test Insert text at current position in rich text field", docFill, True, False, True )
Dim string1 As String
string1 = docFill.sampleText1(0)
Dim rts As NotesRichTextStyle
Set rts = s.CreateRichTextStyle
End Subs
End Sub
Let's say I entered "stackoverflow" in sampleText1 text field. After clicking ok then it will be inserted at the position of the cursor in the rich text field. So the result will be "hellostackoverflow world".
Also just an additional question. Let's say I also wanted the text to be in color red or a different font so I would be using notesrichtextstyle class etc to design it. How would you be able to insert the rich text at the position of the cursor in the rich text fiel if that would be the case?
You can insert text at current cursor position with the help of the clipboard. Just let the user insert text in a dialog box, select the text after clicking "OK", copy it and then paste it at the current cursor position in RichText field back in your form.
To accomplish that, create an action "Insert text" in your form's action bar with the LotusScript code
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
If workspace.DialogBox _
("Dlg", True, True, False, True, _
True, False, "Test insert text", doc, True, False, True ) Then
uidoc.Paste
End If
End Sub
Actions in action bars have the advantage that they don't change the cursor position in document on click event. So, the cursor still remains on current position e.g in RichText field clicking on an action button.
Then, create a form "Dlg" for DialogBox with a Text or RichText field "Text". Add the following formula code to form's Postrecalc event (it's executed on "OK" button click):
#Command([EditGotoField]; "Text");
#Command([EditSelectAll]);
#Command([EditCopy])
You have a lot of options with the copy-paste-approach to put content into clipboard:
Create a text in backend and put it direct into clipboard
Create a RichText item in a temp document with all content and style options you can think of, open the document in UI, copy the RichText item content to clipboard and close document without saving
Let users create their text snippet in documents. Let them choose one of it clicking on "Insert text" button - just open the selected document, copy the content to clipboard and close it.
The first problem is that when you click the action button, you will lose focus of the rich text field, and therefor there is no way to know where the cursor was.
I would also suggest that you don't use the extended notation like this:
string1 = docFill.sampleText1(0)
Use the GetItemValue method of the NotesDocument class instead (for several reasons, including performance and future-proofing your code.
If you just want to have the user enter some text, why not use the InputBox function?
Finally, there is not an easy way to insert text in the middle of a rich text. It is much easier to perform a replace of a specific text string in a rich text field. I once created a Lotusscript class to perform mailmerge (create letters based on a template and a form letter with field names and commands), you can find it here: http://blog.texasswede.com/code-mail-mergeform-letters-in-lotuscript/
Perhaps that can help you some. But it has to be done in the backend, you can't do much rich text work in the frontend, unless you use Midas LSX frpn Ben Langhinrichs (http://www.geniisoft.com). I think he got some UI functionality.
But your biggest issue will be the first problem, how to trigger the code without losing focus of the rich text field. I don't see a good solution there. You may want to rethink your design/approach.
If you use a button in the Action Bar then the focus will remain with the rich text field. You can then use uidoc.InsertText("") to insert the text at the current position of the cursor.
You could use...
call uidoc.InsertText( docFill.sampleText1(0) )

Resources