Running Click event with no result - html

Can someone explain to me why when I click on the following element, the form is not sent. The element is identified however there is no result.
This is the part of the code i am interested in solving, everything up to this point is running fine.
Set IEDoc = Internet.document
Set collection = IEDoc.getElementsByTagName("input") ' there are actually 9 elements
For Each Element In collection
If Element.Type = "image" Then ' there is only the element of interest in here
Element.Click
End If
Next
Here is a sample of the HTML code from the webpage:

Here is a bigger scale of the HTML code from the page in which we can see the form containing the button to submit the information.html code bigger scale
user interface of the webpage

Related

Internet Explorer click an icon and a button of a specific line of a table

I've asked a similar question two days ago but I know stumble again on a similar problem but somehow different. previous question asked on a related problem
I have a report of many lines with the same structure. I need to click an icon that is on the nth line. That report is structured in cells so I know that my icon is in the first position (column) of that report. After I have click that icon I'll also have to click on a button in the 10th column.
I already know how to access the page in question with that code
Sub click_button_no_hlink()
Dim i As Long
Dim IE As Object
Dim Doc As Object
Dim objElement As Object
Dim objCollection As Object
Set IE = CreateObject("InternetExplorer.Application") 'create IE instance
IE.Visible = True
IE.Navigate "https://apex.xyz.qc.ca/apex/prd1/f?p=135:LOGIN_DESKTOP::::::" ' Adress of web page
While IE.Busy: DoEvents: Wend 'loading page
This first part is easy isn't? And I know how to handle it. Afterward I tried different variation around this but it either do nothing, or I get an error message. Obviously I don't fully understand what I'm doing with the "querySelector" thing…
dim step_target as string
step_target = 2
'identify all the lines of my table containing lines, containing icons
'and button to click on
Set objCollection = IE.document.getElementsByClassName("highlight-row")
i = 0
Do While i < objCollection.Length
'cell 2 is the one containing the step I'm targetting
If objCollection.Item(i).Cells(2).innerText = step_target Then
'that's not doing anything
objCollection.Item(i).Cells(9).Click
'tried many syntax around this with no luck
IE.document.querySelector([objCollection.Item(i).Cells(9)]).FireEvent ("onclick")
End If
i = i + 1
Loop
Here's images of the code of the page
Showing all the lines of the report
Showing all code lines of a particular line
and now the code of that first icon I need to click on (this is where I need help ;-) how can I call that action)
and finally the code of that button I also need to click on
Again, I thank you all in advance, for the time you'll take to help me along this.
you could try attribute selector for first in combination with descendant combinator and a type selector
ie.document.querySelector("[headers='ID_DET_DEM_TRAV_STD'] a").click
you could try attribute selector for second in combination with descendant combinator and input type selector
ie.document.querySelector("[headers='BOUTON1'] input").click
alternative for second is
ie.document.querySelector("[value=Fait]").click
Typically, if you want to select by position e.g. 1 and 10th columns you would use
td:nth-of-type(1)
td:nth-of-type(10)
Though you would also use a tr:nth-of-type(n) to get the right row as well e.g. first row, first col. Then add in any child type selector, for example, that you might need.
ie.document.querySelector("tr:nth-of-type(1) td:nth-of-type(1)")
Child a tag:
ie.document.querySelector("tr:nth-of-type(1) td:nth-of-type(1) a")
Child input tag: would then be:
IE.document.querySelector("tr:nth-of-type(4) td:nth-of-type(10) input").Click

Ribbon form. Image object. How to programmatically set the path to the picture in the form element "picture"?

The combox cmb_pic_name is filled with the data from the directory_Pic with the query:
SELECT [directory_Pic].pic_name, [directory_Pic].pic_path FROM directory_Pic;
The user selects the name of the image from the combox cmb_pic_name.
Acces displays the image in the frm_Image (Image object) element.
 
I try to do with the code:
Private Sub cmb_pic_name_AfterUpdate()
Me.frm_Image.Picture = cmb_pic_name.Column(1)
End Sub
Private Sub Form_Load()
frm_Image.Picture = cmb_pic_name.Column(1)
End Sub
Does not work.
 
Question: how to programmatically set the path to the picture in the form element "picture"?
Update_1
Register for the link that is specified in the Gustav solution.
In a single-record form it would work, but your picture control is unbound, thus - in a continuous form - it will display the same picture for all records.
Make the picture control bound to pic_path.
An example for this - though for downloadable pictures - can be found in my article:
Show pictures directly from URLs in Access forms and reports
As you'll see, for each record it retrieves the path to the picture.
Click the link:
Click here to view the full article

MS Access ToggleButton Picture change

I was wondering if it is possible to change the picture of a toggle button in Access VBA depending on the state of the toggle button (pressed and not pressed)?
My previous attempt on doing it included a check if the button's value is "true", but it hasn't really produced a valid result.
If Me.Toggle4.Value = True Then
Me.Toggle4.Picture = "IMAGE"
Else
Me.Toggle4.Picture = "IMAGE"
End If
What the code above produces is the button always having the same image.
It appears that the code seemed to run properly, except that it was place in the incorrect code section. The whole if-else statement was placed in the Form_Load() sub rather than the Toggle4_OnClick(). Special thanks to June7 for the help.

what is the most accurate type for this variable?

here is a part of my code. I managed to get the result I wanted to but only by declaring Elements as a as Variant since it didn't work as a HTMLElementCollection. Can someone explain me why ? And what's the most accurate variable then ? Thanks
' Find + Click on the login Button
' We filter the elements which have the tagename <input> since as we can see in the code that the login element is on of them
Set Elements = IEDoc.getElementsByTagName("input")
For Each element In Elements
If (element.getAttribute("value") = "Login") Then ' we go through each elements with the tagname input and if the value term
element.Click ' is called "Login" then we click on that element
Exit For
End If
Next element

Access VBA Create Word header with text and position picture

Having trouble getting access vba to set a word document's header properly. I've got this.
oDoc.PageSetup.DifferentFirstPageHeaderFooter = True
oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.InlineShapes.AddPicture "C:\Users\mr.helpless\Pictures\doody.jpg"
oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.Text = "hello there"
oDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "whooo hooo!"
What happens right now is the text will replace the picture for the first page (subsequent pages are fine).
I need to have the picture and text - and I need to offset the picture to the left about half an inch while text is centered with normal margins.
Any idea how to go about it? Basically I need to set a document letterhead with a logo.
Update
Dim myText As String
myText = "hello there"
With oDoc.Sections(1).Headers(wdHeaderFooterFirstPage)
.Shapes.AddPicture Filename:="C:\Users\mr.helpless\Pictures\doody.jpg", LinkToFile:=False, SaveWithDocument:=True
.Range.Collapse
.Range.InsertAfter (myText)
.Range.Font.Name = "Helvetica"
.Range.Font.Size = 8
.Range.Font.Bold = True
.Range.Paragraphs.Alignment = wdAlignParagraphCenter
End With
I've got half of it done, now I just need to position the image to -.5 to margin.
Completed Solution
Just add "Left:=-35" to the picture like such (or whatever value works)
.Shapes.AddPicture Filename:="C:\Users\mr.helpless\Pictures\doody.jpg", LinkToFile:=False, SaveWithDocument:=True, Left:=-35
Have you tried recording a macro in Word that does the rough reposition - then bring the code over to Access and edit it for the correct object and size?
All of it is updated in the original thread. it took using the .Range Collapse to add in text along with the image and it took putting Left:=(value) to move it where I needed it.