Selenium VBA code to paste data in browser - vba

I am trying to stimulate the control+v option in a text box in chrome using selenium vba wrapper. I tried using the context click but that function seems to click at a random position based on the cursor position. I tried using the send key function but i am not getting the desired result.
selenium.SendKeys (key.Control & "v")
Please any advise or leads would be much appreciated.

You want to target the text box before using sendkeys. Let's say, hypothetically, that there is an ID called textbox1 for identifying the element then:
driver.FindElementById("textbox1").SendKeys("yourString")
Or
driver.FindElementById("textbox1").SendKeys Keys.Control, "v"
The latter assuming info is already in the clipboard with, for example, driver.SetClipBoard "yourString"

I think you'll be better off using a variable to hold your data rather than the clipboard. Then you can use sendkeys to type it in:
myData= "your data here"
selenium.sendkeys myData
hth

Related

Export Excel Function as a SQL request result

I am facing a weird behavior while exporting an output coming from oracle SQL. I am launching the below query:
select '=sum(1,2)' from dual
Then I right click on the output data and I export it to excel.
I am getting the following result in excel:
The function is presented as a string (the result in the cell is not "3", but rather "=sum(1,2)".
In order to fix this I had to click on the function then click on the Enter button on the keyboard.
excel file picture
Is there a way to force excel to directly understand that the string is a function ?
(I'm assuing you are on SQL Developer here)
There might be other ways, but a little trick I've used in the past is rather tahn Right Click => Export, simply do: Select-All, Copy. Then just Paste into Excel and that seems to preserve the formula definition.
A little animated GIF showing that here
https://imgur.com/a/SJDFjuz
Using the following Macro will fix it. Its a work around to this behavior
for each c in activesheet.usedrange.columns("AD").cells: c.formula=c.formula: next

Searching for specific text in SmarTerm via VBA

I'm looking to search for a specific line of text in a SmarTerm application window opened via VBA and then copy the rest of the row of data into a cell in a worksheet. Previously this was accomplished using a reflection session but I now have no option other than to use SmarTerm.
The code that worked with reflection is:
Found = Session.FindText("SEARCH TEXT", 0, 0)
If Found Then
str_get_string_from_reflection = .GetText(Session.FoundTextRow, 19, Session.FoundTextRow, 60)
Trim (str_get_string_from_reflection)
rng_range_constants_col_A.Offset(0,3).Value = "Search Text: " & str_get_string_from_reflection
End If
Sadly this doesn't work with the SmarTerm solution, I've tried using the Session.StringWait.MatchString command but this doesn't seem to search in the entire visible screen.
Any help that can be offered here will be very much appreciated
I've tried using the SmarTerm Macro Guide (http://www.esker.com/fm/others/eval-smarterm/bin1211/macro.pdf) but can't locate anything other than StringWait.MatchString or StringWait.MatchStringExact that supports searching in the available text. Sadly this only seems to search on the last line of the text, rather than on the whole visible screen.
You could use Session.ScreenText(row, col, page, chars)

How do I fill out fillable PDF Form fields using 4gl?

I have a PDF form that I'm filling out with data using progress-4gl. To date, I've been only filling in text fields using the following syntax:
put stream stream1 unform
"^global CHX_SINGLE_CE_PLAN3" skip(0)
"X" skip
CHX_SINGLE_CE_PLAN3 is the field name...
This code works when dealing with text fields but I'm trying to check a box instead of fill in a text field. I cannot find any documentation on this. Is checking a box on a fillable pdf form even possible with 4gl?
As far as I remember PDF Include has support for filling fillable forms. Whilst it's probably a bit over the top in terms of what you want to achieve, it's an open source project and so you may well find the answer to your question within the code itself.
Here's a link to the project page: http://www.oehive.org/pdfinclude
I discovered the answer, which I thought I had already tried before asking this question. The answer is you need to pass the value "Yes" (with capital "Y") in order to check the checkbox. The correct code in this instance is:
put stream stream1 unform
"^global CHX_SINGLE_CE_PLAN3" skip(0)
"Yes" skip
I believe this is the case no matter which language you're using

VBA - Word Table : default value and combo box

I have Word Tables, and I don't find how to affect default values for certain columns...
When inserting a new line, I would like a certain column to have a certain drop-down list without user having to do it himself.
To illustrate my thoughts, here is a small image of what I'm looking for
I really don't find how to manipulate my table for it to ends up like this, so I would like to request your help.
When looking on the web for this, I only find information about table default style and no default Value.
So I would like to ask. Is this possible? If yes, how to do it?
I am looking for either a VBA code to set my column default value (which would be great), or even a way to do it in Word GUI at first. Or, obviously, an answer that would tell me that it is impossible to do in Word.
PS: the extremely easy equivalent in Excel of what i'm looking for:
Thanks in advance!
In the GUI:
Click the cell where you would like your dropdown.
In menu, switch to "Developer Tools"
Insert a Dropdown control ("Controls" are, the one in the middle)
In the ribbon, click "Design mode" (I have German Word so the actual name might differ), "Properties"
Now you can enter your options
Alternatively via VBA, I got this with the macro recorder; should give you a start:
[Cell].Range.ContentControls.Add (wdContentControlComboBox)
ActiveDocument.ToggleFormsDesign
Selection.ParentContentControl.DropdownListEntries.Clear
Selection.ParentContentControl.DropdownListEntries.Add Text:="Yes", Value _
:="Yes"
Selection.ParentContentControl.DropdownListEntries.Add Text:="No", Value:= _
"No"

Insert image from URL bookmark Microsoft word

I have a image URL contained in my sql database.
I create a bookmark for that column in the word document (this works fine).
Now I want to use the image URL that is passed from the database to insert an image.
I have tried hyperlink (does not work and does not display image).
I have tried Quick Parts - IncludePicture (does not work).
I have been Googleing and have not found anything that works.
Ok let me simplify this.
I want to insert a image using an URL.
You can do this in alot of different ways I know.
For instance using Quick Parts and the selecting IncludePicture you would the past the URL of the picture and BAM image inserted.
Now I want to do exactly that with one exception. The URL is a microsoft word bookmark that I get from my database.
For some reason this does not want to work. I have also checked the bookmark data and it is correct and yes it is a valid URL because if I copy and paste it from the database in the way I described above it works.
So is there any other way to do this?
To be honest I still don't know where is exactly your problem. I assumed that you have knowledge and code to take both bookmark name and url from your database using VBA. If so, there would be quite simple code which would allow you to load picture from web to bookmark in your word document.
Below is the code I have tested with half of success. If I add any picture it will work fine. But will not work with url of active google map. I have no idea what you you mean with 'static google map' (in comment), you didn't provide any example therefore you need to make your own test.
Before you run this for test be sure you have two bookmarks in your active document: bookmark_logo and bookmark_poland. Hope this will help a bit.
Sub Insert_picture_To_Bookmark()
Dim mapURL As String
Dim soLOGO As String
soLOGO = "http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png"
ActiveDocument.Bookmarks("bookmark_logo"). _
Range.InlineShapes.AddPicture _
soLOGO, True, True
mapURL = "https://maps.google.pl/maps?q=poland&hl=pl&sll=50.046766,20.004863&sspn=0.22047,0.617294&t=h&hnear=Polska&z=6"
ActiveDocument.Bookmarks("bookmark_poland"). _
Range.InlineShapes.AddPicture _
mapURL, True, True
End Sub