I am new here/to programming. I am trying to use VBA to input some text into a webpage through internet explorer.
I am able to open explorer through VBA and navigate to the page, but I am unable to enter text in the searchbar. When I click "inspect element" on the search bar, it returns this:
<input class="ui-autocomplete-input" id="la-input"
maxlength="2147483647"
placeholder="Search by Name, Last Name, First Name, or Account Name"
autocomplete="off">
This is the code I am trying to modify to get to run:
'get a reference to the search form, by finding its id in the
'web page's document object model
Dim ieElement As Object
Set ieElement = ieApp.document.getElementByID("search")
'search box is composed of text box (item 0) and button (item 1)
'set value of text box to what we're searching for
ieElement(0).Value = "Excel VBA courses"
'click the button!
ieElement(1).Click
Thank you!!
Related
I am very new to Selenium and I'm trying to create an application, which gets some information from an excel sheet, logs into a specific facebook page (not a person's profile), and creates a post which contains an image.
So far I've managed to log into the page account but I have no clue on how to upload a certain image due to the fact that it seems that the webdriver cannot interact with the filedialog that appears if I (programmatically) click on the "upload image" button. Also I cannot find any "upload" id or whatsoever.
Posting here the code I need help with:
' After having logged in, this creates a post
Dim ele As WebElement
Dim drv As New WebDriver
Set ele = drv.FindElementByXPath("//*[#aria-label='Crea un post']") ' This selects the "create a new post" button
ele.Click
Application.Wait (100)
If Not IsEmpty(Cells(24, 2)) Then ' Adds picture if there is one specified in the excel sheet
Set ele = drv.FindElementByXPath("//*[#aria-label='Foto/video']") ' This clicks the "add Picture" button, but then the FileDialog appears and I cannot interact with it
ele.Click
ele.SendKeys "C:\mytestimage.png"
End If
Set ele = drv.FindElementByXPath("//*[#aria-label='Scrivi qualcosa a mypage']") ' Italian for "write something to mypage"
ele.SendKeys "Whatever I want to be written in the post"
Is there any way I can insert an html link into a textbox using VBA? I've created a dialog with a textbox, I would like to convert the text to a web link, then insert it to the textbox in the document.
Dim WO_Box1 As Shape
Set WO_Box1 = ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, Left:=17, Top:=125, Width:=106.5, Height:=19)
WO_Box1.TextFrame.TextRange.Font.Name = "Tahoma"
WO_Box1.TextFrame.TextRange.Font.Size = "9"
WO_Box1.TextFrame.TextRange.Text = TextBox1.Text
WO_Box1.TextFrame.TextRange.Hyperlinks.Add Anchor:=WO_Box1.TextFrame.TextRange, Address:=TextBox1.Text, TextToDisplay:=TextBox1.Text
The Anchor is the textbox you are working with. You can use any text for TextToDisplay but the Address should be assigned to the actual hyperlink url.
I try to do the embed a hyperlink in a textbox (rich text) in a MS Access form . Would this be possible? Didn't found any solution in the web so far...
Something like:
Me.TextWithLink = "Text here for link <b> Hyperlink Text</b>"
PS: Textbox is set to RichText, tried to set to hyperlink true/false but not working...
Is there any workaround?
Form_Formular1.Text0.Value = "your text http://www.google.de"
Would produce automatically
As well as
Form_Formular1.Text0.Value = "your text http://www.google.de"
but obviously the URL and the hyperlink text needs to be the same. So
Form_Formular1.Text0.Value = "your text " & url & ""
I have a connection to an internet explorer webpage but i cannot seem to "click" a specific link using vba7 in access. I've tried loads of options like getelementsbyclassname. Here's the source code from the webpage:
<tr>
<td valign=bottom class="formbutton" align=center colspan=2>
view
</td>
</tr>
As you can see it has no name nor a usable hyperlink and the purpose of this link is to submit the filled-out form and give it a unique number on a new web page.
Can you please help me in VBA 7 for Access 2007 to come up with a vba code that works?
Many thanks!
The following should work assuming you have a pointer to the InternetExplorer object already.
Public Sub ClickElement()
'Assuming you already have an IE object
Dim Elements As Object
Dim Element As Object
'get all 'A' tags, which the hyperlink is part of
Set Elements = IE.Document.getElementsByTagName("a")
For Each Element In Elements
'I believe the element you want to click appears as 'View' on screen
If Element.InnerText = "View" Then
'Usually a good idea to give the element focus and
'possibly fire the OnClick event, but sometimes not needed
Element.Focus
Element.Click
Element.FireEvent ("OnClick")
Exit For
End If
Next
End Sub
I have a VSTO Excel Addin solution which exposes certain methods to VBA through a ComVisible interface. Please refer this for a sample implementation. I am using VSTO 4 and Excel 2007/2010 for this.
Certain methods of the exposed interface insert a control (button, combo box or a Winform UserControl) when called from VBA. The method executes properly and inserts the control on the sheet as well.
public void AddButtonControl(string strControlName)
{
Microsoft.Office.Interop.Excel.Worksheet nativeWorksheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet;
Microsoft.Office.Tools.Excel.Worksheet vstoWorksheet = Globals.Factory.GetVstoObject(nativeWorksheet);
vstoWorksheet.Controls.AddButton(nativeWorksheet.Range["A1", "E5"], strControlName);
}
Now as soon as the control is inserted in the workbook, all the variables declared in VBA are reset. All code goes back to the state as if it were never executed.
My solution and an Excel workbook are shared here
Just build the solution and open the workbook SampleTest.xlsm
Click "Check string value", a message box saying "Default Text" would be displayed.
Click on button - "Add Button Dynamically". A button would be inserted at the top of the sheet. and a message saying - "Assigning text to string: Sample Text" would be displayed.
Now click "Check string value" again. It should have displayed "Sample Text" but a blank message box is displayed.
Any suggestions/workarounds are welcome.