Results 1 to 11 of 11

Thread: www.upcdatabase.com

  1. #1

    Thread Starter
    Fanatic Member bob5731's Avatar
    Join Date
    Nov 2004
    Posts
    918

    Angry www.upcdatabase.com

    Hi
    Need to save all the date in ms access 2003 forum www.upcdatabase.com
    code in vba
    Attached Files 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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: www.upcdatabase.com

    VBA question moved to Office Development.

  3. #3
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    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:
    1. Private Sub Command1_Click()
    2.     Dim hBut As HTMLInputButtonElement
    3.     Dim iStart As Integer
    4.     Dim iEnd As Integer
    5.     iStart = 0
    6.     iEnd = 0
    7.     If WebBrowser1.LocationURL <> "http://www.upcdatabase.com/nocheckdigit.pl" Then
    8.         WebBrowser1.Navigate2 "http://www.upcdatabase.com/nocheckdigit.pl"
    9.     End If
    10.     Do While WebBrowser1.Busy = True
    11.         DoEvents
    12.         Sleep 500
    13.     Loop
    14.     Set hDoc = WebBrowser1.Document
    15.     Set hInp = hDoc.getElementById("upc")
    16.     hInp.focus
    17.     hInp.Value = "07800008846"
    18.    
    19.     For Each hBut In hDoc.getElementsByTagName("INPUT")
    20.       If hBut.Name = "" Then Exit For
    21.     Next
    22.    
    23.     hBut.Click
    24.        
    25.     Do While WebBrowser1.Busy = True
    26.         DoEvents
    27.         Sleep 500
    28.     Loop
    29.    
    30.     Set hInp = Nothing
    31.     'Parse the elements and read the values of the data returned
    32.     'Set document variable = to the new results documents page
    33.     Set hDoc = WebBrowser1.Document
    34.     'Find the description:
    35.     iStart = InStr(1, hDoc.body.innerHTML, "<TD>Description</TD>") + 37
    36.     iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
    37.     MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
    38.     'Find the Size/Weight:
    39.     iStart = InStr(iStart, hDoc.body.innerHTML, "<TD>Size/Weight</TD>") + 37
    40.     iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
    41.     MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
    42.     'Find Manufacturer:
    43.     iStart = InStr(iStart, hDoc.body.innerHTML, "<TD>Manufacturer</TD>") + 38
    44.     iEnd = InStr(iStart, hDoc.body.innerHTML, "(<A href=")
    45.     MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
    46.     'Find the Entered/Modified:
    47.     iStart = InStr(iStart, hDoc.body.innerHTML, "<TD>Entered/Modified</TD>") + 42
    48.     iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
    49.     MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
    50. End Sub
    This world is not my home. I'm just passing through.

  4. #4

    Thread Starter
    Fanatic Member bob5731's Avatar
    Join Date
    Nov 2004
    Posts
    918

    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

  5. #5
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    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.

  6. #6

    Thread Starter
    Fanatic Member bob5731's Avatar
    Join Date
    Nov 2004
    Posts
    918

    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

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: www.upcdatabase.com

    What part of what trisuglow posted won't work in VBA?

    Have you tried it in VBA?

  8. #8
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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

  9. #9

    Thread Starter
    Fanatic Member bob5731's Avatar
    Join Date
    Nov 2004
    Posts
    918

    Angry Re: www.upcdatabase.com

    VB Code:
    1. Option Explicit
    2. 'Add component to Microsoft HTML Object Library
    3. 'Add component Microsoft Internet Controls
    4.  
    5. 'Add a command button (Command1)
    6. 'Add a web browser control to the form (wbbWebsite)
    7. Dim hDoc 'As MSHTML.HTMLDocument
    8. Dim hCol 'As MSHTML.IHTMLElementCollection
    9. Dim hInp 'As MSHTML.HTMLInputElement
    10. Dim hSub 'As MSHTML.HTMLInputButtonElement
    11. Dim hTxt 'As MSHTML.HTMLInputTextElement
    12. Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    13. Private Sub Form_Load()
    14.     'Application.Screen.MousePointer = 11 ' Hourglass
    15.     'wbbWebsite.Navigate URL:="http://www.upcdatabase.com/nocheckdigit.pl"
    16.     'MsgBox "**** You"
    17.     'Application.Screen.MousePointer = 0 ' Back to normal
    18.     wbbWebsite.Navigate URL:="http://www.upcdatabase.com/item.pl?upc"
    19.     MsgBox "Hello"
    20. End Sub
    21. Private Sub Command1_Click()
    22. wbbWebsite.Navigate URL:="http://www.upcdatabase.com/item.pl?upc"
    23. MsgBox "Hello"
    24. Set hDoc = wbbWebsite.Document
    25.     Set hInp = hDoc.getElementById("upc")
    26.     'hInp.focus
    27.     'upc = "064144043248"
    28.     hInp.Value = upc
    29.     Set hInp = Nothing
    30.     'Parse the elements and read the values of the data returned
    31.     'Set document variable = to the new results documents page
    32.     Set hDoc = wbbWebsite.Document
    33.     'Find the description:
    34.     'iStart = InStr(1, hDoc.body.innerHTML, "<TD>Description</TD>") + 37
    35.     'iEnd = InStr(iStart, hDoc.body.innerHTML, "</TD></TR>")
    36.     'MsgBox Mid$(hDoc.body.innerHTML, iStart, iEnd - iStart)
    37. End Sub
    38. Private Sub Command2_Click()
    39. On Error GoTo Err_Command2_Click
    40.     Dim stDocName As String
    41.     stDocName = "food"
    42.     DoCmd.OpenDataAccessPage stDocName, acDataAccessPageBrowse
    43. Exit_Command2_Click:
    44.     Exit Sub
    45. Err_Command2_Click:
    46.     MsgBox Err.Description
    47.     Resume Exit_Command2_Click
    48. End Sub
    49. Private Sub upc_Change()
    50.     wbbWebsite.Navigate URL:="http://www.upcdatabase.com/item.pl?upc"
    51.     MsgBox "Hello"
    52.     Set hDoc = wbbWebsite.Document
    53.     Set hInp = hDoc.getElementById("upc")
    54.     hInp.Value = upc
    55.     Set hInp = Nothing
    56. End Sub
    Attached Files 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

  10. #10
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    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

  11. #11

    Thread Starter
    Fanatic Member bob5731's Avatar
    Join Date
    Nov 2004
    Posts
    918

    Re: www.upcdatabase.com

    I do not know.
    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
  •  



Click Here to Expand Forum to Full Width