+ Reply to Thread
Results 1 to 7 of 7

Thread: Transfering Value from Table in Web with Multiple Page Include saving Images

  1. #1
    Registered User
    Join Date
    02-04-2012
    Location
    jakarta
    MS-Off Ver
    Excel 2007
    Posts
    5

    Transfering Value from Table in Web with Multiple Page Include saving Images

    Hey Master,

    I'm a beginner here. I've read a few posts similar to this topic, but nothing have images in there.
    The pages are password protected, but I send attachment maybe it would help.

    Each page follows in order, 1, 2, etc. I'm pulling information from the same table on each page, and each page is formatted identically.
    What I want is transfer the table to one sheet and save image to my local directory with file name identically to field "Product Number".
    for example : 00006.jpg

    Thanks in advance for your help.
    I apologize if this was covered somewhere else (I've searched several times).
    And I'am sorry if my English was so bad....

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    Hello yvanka,

    Welcome to the Forum!

    After looking at the table, it looks like the picture your are referring to is in the "Barcode" column. Is that correct?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-04-2012
    Location
    jakarta
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    Yes that's correct,
    i want to transfering data from the table in a one sheet

    No | Product Number | Product Name | Brand Name | Category | Dimension | Package | Barcode | Date

    Barcode Column is only contain picture that I want to save. So in my sheet just let it empty.
    And I want to save the barcode picture with name from product number.
    For example : 00006.jpg

    I hopes that clear enough.
    Thanks a lot

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    Hello yvanka,

    Thanks, that's perfectly clear. Which row and column will the data be transferred to?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    Hello yvanka,

    Thanks, that's perfectly clear. Which row and column will the data be transferred to?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    02-04-2012
    Location
    jakarta
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    Thanks Leith Ross,

    So Which row and column will the data be transferred to?
    What I need is just read the table from webpage and write it on my worksheet.

    Maybe like preview images that i've sent...
    ups I'm sorry... I don't know why it can't be sent ...

    http://i920.photobucket.com/albums/a...ka/preview.png

    thanks ...

  7. #7
    Registered User
    Join Date
    02-04-2012
    Location
    jakarta
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    In that picture that link i sent, it's display what i want in my sheet and preview picture image that i want to save from webpage in a format filename like i want.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    Hello yvanka,

    The attached workbook has the macro below installed. On "Sheet1", row 1 is the header row. There is button added to the row to run the macro.

    The macro will attach to a running instance of Internet Explorer. The title in the window is expected to be "Member Area - GS1 Indonesia". If it is not then the title must be changed in the macro. All pictures will be downloaded to the file path in the picture you posted. Change this if you need to.

    
    ' Thread:  http://www.excelforum.com/excel-programming/812908-transfering-value-from-table-in-web-with-multiple-page-include-saving-images.html
    ' Poster:  yvanka
    ' Author:  Leith Ross
    ' Written: February 04, 2012
    
    Private Declare Function DownloadPicture _
        Lib "urlmon.dll" _
        Alias "URLDownloadToFileA" _
          (ByVal pCaller As Long, _
           ByVal szURL As String, _
           ByVal szFileName As String, _
           ByVal dwReserved As Long, _
           ByVal lpfnCB As Long) _
        As Long
    
    
    Sub CopyWebTable()
    
        Dim Data As Variant
        Dim I As Long
        Dim ieApp As Object
        Dim R As Long
        Dim ShellApp As Object
        Dim PageSource As String
        Dim Pic As Variant
        Dim PicFolder As String
        Dim PicSource As String
        Dim Table As Object
        Dim TableRows As Object
        Dim Tables As Object
        Dim Text As String
        Dim Title As String
        Dim Wks As Worksheet
        Dim Wnd As Object
            
            Title = "Member Area - GS1 Indonesia"
            
            PicFolder = "C:\Documents and Settings\pradhita\My Documents\Downloads\Images\"
                
            Set Wks = Worksheets("Sheet1")
            
            Set Rng = Wks.Range("A2")
            
                    R = Wks.Cells(Rows.Count, Rng.Column).End(xlUp).Row
                    R = IIf(R < Rng.Row, 0, R - Rng.Row + 1)
                    
                    Set ShellApp = CreateObject("Shell.Application")
                    
                    For Each Wnd In ShellApp.Windows
                        If Wnd.Name = "Windows Internet Explorer" Then
                           If Wnd.LocationName = Title Then
                              Set ieApp = Wnd
                              PageSource = Wnd.Document.Body.innerHTML: Exit For
                           End If
                        End If
                    Next Wnd
                    
                    If ieApp Is Nothing Then
                       MsgBox "Please start Internet Explorer," & vbCrLf _
                             & "log in and try again."
                       Exit Sub
                    End If
                    
                    PageSource = Replace(PageSource, vbLf, "")
                    PageSource = Replace(PageSource, vbCr, "")
                    PageSource = Replace(PageSource, vbTab, "")
                    
                    Set Tables = ieApp.Document.Body.getElementsByTagName("table")
                    Set Table = Tables(2)
    
                    Set TableRows = Table.Rows
                    
                        For I = 1 To TableRows.Length - 1
                            ReDim Data(8)
                            With TableRows(I)
                                Data(0) = .Cells(0).ChildNodes(0).innerHTML
                                Data(1) = .Cells(1).ChildNodes(0).innerHTML
                                Data(2) = .Cells(2).ChildNodes(0).innerHTML
                                Data(3) = .Cells(3).ChildNodes(0).innerHTML
                                Data(4) = .Cells(4).ChildNodes(0).innerHTML
                                Data(5) = .Cells(5).ChildNodes(0).innerHTML
                                Data(6) = .Cells(6).ChildNodes(0).innerHTML
                                Data(7) = Data(1) & ".jpg"
                                Data(8) = .Cells(8).ChildNodes(0).innerHTML
                                PicFile = PicFolder & Data(7)
                                PicSource = .Cells(7).ChildNodes(0).src
                            End With
                            
                            Call DownloadPicture(0, PicSource, PicFile, 0, 0)
                            
                            Rng.Offset(R, 0).Resize(1, 9).Value = Data
                            R = R + 1
                        Next I
                    
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Registered User
    Join Date
    02-04-2012
    Location
    jakarta
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Transfering Value from Table in Web with Multiple Page Include saving Images

    ok thanks a lot ....
    let me try this before

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0