chacanger
01-06-2011, 04:14 PM
Hi
I'm currently trying to automate a program which works both in the format of an exe file and in the form of an aspx page. I have most of the code I need but there is a slight issue with getting VBA to press Enter and F12. I've tried many examples but they don't seem to work for my scenario.
I decided it was easier to use the aspx site rather than the exe file,
unfortunately I can't give a link to the aspx site. However it's kind of like a form were you input information, except that the other fields only appear after you complete the previous one and press enter, there is no buttons to press to proceed to the next field, so this is were I'm stuck trying to press Enter on Internet Explorer and F12 which is required at the end. Basiclly so far I can open Internet Explorer and type in the first message box and press buttons if required. Sorry it sounds a bit confusing.
I have managed to produce some code to replicate the same thing on Google and have put in a version for my aspx program without the link name to get the gist of how it looks. The input boxes all have the same name so in this example "p" in google is the Search Box were as in the aspx I need to type into is called TEXTINPUT.
Sub IE_Run_Google()
'----------------Google Example...
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Navigate "Google Website"
'Loop until it has loaded.
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Visible = True
ie.AddressBar = False
ie.Toolbar = False
ie.Document.getelementbyID("q").Value = "VBA Example"
'---------------Needs to press enter here or F12
Set ie = Nothing
End Sub
Sub IE_Run_Myprogram()
'----------------How my ASPX Example works...
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Navigate "my aspx link"
'Loop until it has loaded.
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Visible = True
ie.AddressBar = False
ie.Toolbar = False
ie.Document.getelementbyID("TEXTINPUT").Value = "OI"
'---------------Needs to press enter here
ie.Document.getelementbyID("TEXTINPUT").Value = "N"
'---------------Needs to press enter here
ie.Document.getelementbyID("TEXTINPUT").Value = "000000000"
'---------------Needs to press enter here
ie.Document.getelementbyID("TEXTINPUT").Value = "0000"
'---------------Needs to press enter here or F12
Set ie = Nothing
End Sub
Your help is much appreciated
I'm currently trying to automate a program which works both in the format of an exe file and in the form of an aspx page. I have most of the code I need but there is a slight issue with getting VBA to press Enter and F12. I've tried many examples but they don't seem to work for my scenario.
I decided it was easier to use the aspx site rather than the exe file,
unfortunately I can't give a link to the aspx site. However it's kind of like a form were you input information, except that the other fields only appear after you complete the previous one and press enter, there is no buttons to press to proceed to the next field, so this is were I'm stuck trying to press Enter on Internet Explorer and F12 which is required at the end. Basiclly so far I can open Internet Explorer and type in the first message box and press buttons if required. Sorry it sounds a bit confusing.
I have managed to produce some code to replicate the same thing on Google and have put in a version for my aspx program without the link name to get the gist of how it looks. The input boxes all have the same name so in this example "p" in google is the Search Box were as in the aspx I need to type into is called TEXTINPUT.
Sub IE_Run_Google()
'----------------Google Example...
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Navigate "Google Website"
'Loop until it has loaded.
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Visible = True
ie.AddressBar = False
ie.Toolbar = False
ie.Document.getelementbyID("q").Value = "VBA Example"
'---------------Needs to press enter here or F12
Set ie = Nothing
End Sub
Sub IE_Run_Myprogram()
'----------------How my ASPX Example works...
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Navigate "my aspx link"
'Loop until it has loaded.
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Visible = True
ie.AddressBar = False
ie.Toolbar = False
ie.Document.getelementbyID("TEXTINPUT").Value = "OI"
'---------------Needs to press enter here
ie.Document.getelementbyID("TEXTINPUT").Value = "N"
'---------------Needs to press enter here
ie.Document.getelementbyID("TEXTINPUT").Value = "000000000"
'---------------Needs to press enter here
ie.Document.getelementbyID("TEXTINPUT").Value = "0000"
'---------------Needs to press enter here or F12
Set ie = Nothing
End Sub
Your help is much appreciated