Hi guys,
I'm new here and I've never accessed websites via VBA, therefore, I'm a little bit inexperienced... excuse me in advance.
Introduction:
I'd like to use VBA to get information from a production database (openable via internet explorer) and import them into an excel-list for some analyses.
After some research I got this to open the database (inet explorer), which works well:
Problem No. 1:
To get the wanted data you have to select a couple of comboboxes and option fields (product, date, time, device etc.)
There are comoboboxes with and without values for each list-item:
The following VBA-Code works only for the comoboxes with values:
I have no idea how to automatically select the right item for the non-value-boxes
Problem No. 2:
There are six RadioButtons for the time frame (daily, monthly, ...). The source code shows me that they all have the same name "pdate", but different values "0", "1", ..., "5".
If tried a few things:
Unfortunately, it didn't work that fine.
I really appreciate your help!
I'm new here and I've never accessed websites via VBA, therefore, I'm a little bit inexperienced... excuse me in advance.
Introduction:
I'd like to use VBA to get information from a production database (openable via internet explorer) and import them into an excel-list for some analyses.
After some research I got this to open the database (inet explorer), which works well:
Code:
'my VBA-Code
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = False
ie.Navigate [URL]http://url.....[/URL]
Problem No. 1:
To get the wanted data you have to select a couple of comboboxes and option fields (product, date, time, device etc.)
There are comoboboxes with and without values for each list-item:
Code:
'source code
'with values:
<
[SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]value[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]="RJ">[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Screw[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]value[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]="R9">[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Shaft[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#ff0000][SIZE=2][COLOR=#ff0000]value[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]="RN">[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]Nozzle[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]'...
'without values:
[SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<
[SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]1[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]2[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]3[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]OPTION[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]4[/SIZE]
[/COLOR][/SIZE]
[/COLOR][/SIZE][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]
The following VBA-Code works only for the comoboxes with values:
Code:
ie.document.getElementByID("pproduct").Value = "8401"
ie.document.getElementByID("ptest").Value = "4"
ie.document.getElementByID("pfamily").Value = "RJ" '--> selects "Screw"
ie.document.getElementByID("pgroup").Value = "01"
I have no idea how to automatically select the right item for the non-value-boxes
Problem No. 2:
There are six RadioButtons for the time frame (daily, monthly, ...). The source code shows me that they all have the same name "pdate", but different values "0", "1", ..., "5".
If tried a few things:
Code:
ie.document.getElementByID("pdate").Item(4).Checked = True
ie.document.getElementByID("pdate").Item.Checked = True 'RadioButton with value = "0" is being selected
ie.document.getElementByID("pdate").Checked = True 'RadioButton with value = "0" is being selected
ie.document.getElementByID("pdate").Item(4).Click
Unfortunately, it didn't work that fine.
I really appreciate your help!