Oct 12th, 2005, 10:26 PM
#1
Thread Starter
Fanatic Member
www.upcdatabase.com
Hi
Need to save all the date in ms access 2003 forum www.upcdatabase.com
code in vba
Attached Files
Last edited by bob5731; Oct 12th, 2005 at 11:56 PM .
P.S. God Love You And Have A Good Day!!!
My web page
I need to get a free Iphone
Oct 13th, 2005, 06:19 AM
#2
Re: www.upcdatabase.com
VBA question moved to Office Development.
Oct 13th, 2005, 06:40 AM
#3
Re: www.upcdatabase.com
Bob,
Thanks for your question. I'm not yet an HTML expert, but looking at this problem has got me started
This replacement code appears to work perfectly in debug mode if you single step through it. Running at full speed however suffers from some timing problems.
Anyway, your problem seems to stem from the fact that SendKeys wasn't working and its difficult to identify the button on the form because it hasn't been given a name. This code gets round the problem though.
VB Code:
Private Sub Command1_Click()
Dim hBut As HTMLInputButtonElement
Dim iStart As Integer
Dim iEnd As Integer
iStart = 0
iEnd = 0
If WebBrowser1.LocationURL <> "http://www.upcdatabase.com/nocheckdigit.pl" Then
WebBrowser1.Navigate2 "http://www.upcdatabase.com/nocheckdigit.pl"
End If
Do While WebBrowser1.Busy = True
DoEvents
Sleep 500
Loop
Set hDoc = WebBrowser1.Document
Set hInp = hDoc.getElementById("upc")
hInp.focus
hInp.Value = "07800008846"
For Each hBut In hDoc.getElementsByTagName("INPUT")
If hBut.Name = "" Then Exit For
Next
hBut.Click
Do While WebBrowser1.Busy = True
DoEvents
Sleep 500
Loop
Set hInp = Nothing
'Parse the elements and read the values of the data returned
'Set document variable = to the new results documents page
Set hDoc = WebBrowser1.Document
'Find the description:
iStart = InStr(1, hDoc.body.innerHTML, "<TD>Description</TD>") + 37
iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
'Find the Size/Weight:
iStart = InStr(iStart, hDoc.body.innerHTML, "<TD>Size/Weight</TD>") + 37
iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
'Find Manufacturer:
iStart = InStr(iStart, hDoc.body.innerHTML, "<TD>Manufacturer</TD>") + 38
iEnd = InStr(iStart, hDoc.body.innerHTML, "(<A href=")
MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
'Find the Entered/Modified:
iStart = InStr(iStart, hDoc.body.innerHTML, "<TD>Entered/Modified</TD>") + 42
iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
End Sub
This world is not my home. I'm just passing through.
Oct 13th, 2005, 10:22 AM
#4
Thread Starter
Fanatic Member
Re: www.upcdatabase.com
Hi
Tha code in vb 6.0 but I need in vbs.
Can You all help me get it into vba?
P.S. God Love You And Have A Good Day!!!
My web page
I need to get a free Iphone
Oct 13th, 2005, 10:25 AM
#5
Re: www.upcdatabase.com
Sorry, looks like I misunderstood the question.
Haven't got the time now to help convert it to VBA. PM me next week if you don't get help from anybody else.
This world is not my home. I'm just passing through.
Oct 13th, 2005, 10:27 AM
#6
Thread Starter
Fanatic Member
Re: www.upcdatabase.com
can you help get start for now?
P.S. God Love You And Have A Good Day!!!
My web page
I need to get a free Iphone
Oct 13th, 2005, 12:59 PM
#7
Re: www.upcdatabase.com
What part of what trisuglow posted won't work in VBA?
Have you tried it in VBA?
Oct 13th, 2005, 01:37 PM
#8
Frenzied Member
Re: www.upcdatabase.com
He probably needs the Library Reference for starters!
Hey! I found it! Microsoft HTML Object Library
He'll also need:
Code:
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Public Sub Workbook_Open()
Sleep 5000 'Implements a 5 second delay
End Sub
If he is using Option Explicit he'll need a Dim for "WebBrowser1"
Last edited by Webtest; Oct 13th, 2005 at 01:54 PM .
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
Oct 13th, 2005, 02:08 PM
#9
Thread Starter
Fanatic Member
Re: www.upcdatabase.com
VB Code:
Option Explicit
'Add component to Microsoft HTML Object Library
'Add component Microsoft Internet Controls
'Add a command button (Command1)
'Add a web browser control to the form (wbbWebsite)
Dim hDoc 'As MSHTML.HTMLDocument
Dim hCol 'As MSHTML.IHTMLElementCollection
Dim hInp 'As MSHTML.HTMLInputElement
Dim hSub 'As MSHTML.HTMLInputButtonElement
Dim hTxt 'As MSHTML.HTMLInputTextElement
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
'Application.Screen.MousePointer = 11 ' Hourglass
'wbbWebsite.Navigate URL:="http://www.upcdatabase.com/nocheckdigit.pl"
'MsgBox "**** You"
'Application.Screen.MousePointer = 0 ' Back to normal
wbbWebsite.Navigate URL:="http://www.upcdatabase.com/item.pl?upc"
MsgBox "Hello"
End Sub
Private Sub Command1_Click()
wbbWebsite.Navigate URL:="http://www.upcdatabase.com/item.pl?upc"
MsgBox "Hello"
Set hDoc = wbbWebsite.Document
Set hInp = hDoc.getElementById("upc")
'hInp.focus
'upc = "064144043248"
hInp.Value = upc
Set hInp = Nothing
'Parse the elements and read the values of the data returned
'Set document variable = to the new results documents page
Set hDoc = wbbWebsite.Document
'Find the description:
'iStart = InStr(1, hDoc.body.innerHTML, "<TD>Description</TD>") + 37
'iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
'MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
End Sub
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim stDocName As String
stDocName = "food"
DoCmd.OpenDataAccessPage stDocName, acDataAccessPageBrowse
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
Private Sub upc_Change()
wbbWebsite.Navigate URL:="http://www.upcdatabase.com/item.pl?upc"
MsgBox "Hello"
Set hDoc = wbbWebsite.Document
Set hInp = hDoc.getElementById("upc")
hInp.Value = upc
Set hInp = Nothing
End Sub
Attached Files
Last edited by bob5731; Oct 13th, 2005 at 02:12 PM .
P.S. God Love You And Have A Good Day!!!
My web page
I need to get a free Iphone
Oct 13th, 2005, 02:27 PM
#10
Frenzied Member
Re: www.upcdatabase.com
Is there a References Library Function that can be used if you just use code and don't use a WebBrowser Control?
wbbWebsite.Navigate
wbbWebsite.Document
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
Oct 13th, 2005, 02:28 PM
#11
Thread Starter
Fanatic Member
P.S. God Love You And Have A Good Day!!!
My web page
I need to get a free Iphone
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width