Consulting

Results 1 to 5 of 5

Thread: List of adds to repost to Web Site (Web Automation)

  1. #1
    VBAX Regular
    Joined
    Sep 2013
    Posts
    37
    Location

    List of adds to repost to Web Site (Web Automation)

    Here is the deal. I have a bunch of adds I Post to this site all the time, and I want to be able to automate the process. Where I am struggling is it looks like the VBA cant just set a value to the second combobox, I have looked through the source code, and it appears that some kind of function is run and the second combobox has cascading parameters to the first combo box meaning it is dependent on the results of the first combobox. How can I fill in a value here. I work for a furniture store and my code updates the first box with furniture. Can someone help me populate the second Box and click go?

    Thanks

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    You realize that we're going to have to see your code?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Sep 2013
    Posts
    37
    Location
    oh my I am such a jabroni... lol sorry about that. Here is the code. I figured out that answer, but now I am having something that is way over my head. And I thought I was advance >_<


    Sub go_Net()
    
    Set objie = CreateObject("InternetExplorer.Application")
    objie.Top = 0
    objie.Left = 0
    objie.Width = 800
    objie.Height = 600
    objie.Visible = True
    objie.Navigate ("https://www.ksl.com/public/member/signin")
    On Error Resume Next
    
    'Range("email").Value
    'Range("password").Value
    the_start:
    Do
    DoEvents
    If Err.Number < 0 Then
    objie.Quit
    Set objie = Nothing
    GoTo the_start:
    End If
    Loop Until objie.ReadyState = 4
     
    
    Email = Range("email").Value 'InputBox("Enter email")
    Password = Range("password").Value 'InputBox("Enter password")
    Do
    DoEvents
    If Err.Number < 0 Then
    objie.Quit
    Set objie = Nothing
    GoTo the_start:
    End If
    Loop Until objie.ReadyState = 4
     
     
    Call objie.Document.getElementById("memberemail").setAttribute("value", Email)
    Call objie.Document.getElementById("memberpassword").setAttribute("value", Password)
    Call objie.Document.forms(1).submit
    
    the_start2:
    Do
    DoEvents
    Loop Until objie.ReadyState = 4
    
    If Err.Number < 0 Then
    objie.Quit
    Set objie = Nothing
    GoTo the_start2:
    End If
     
    Set allhyperlinks = objie.Document.getElementsByTagName("A")
     
    For Each hyper_link In allhyperlinks
    If hyper_link.innerText = "Classifieds" Then
    hyper_link.Click
    End If
    Next
     
    Do
    DoEvents
    Loop Until objie.ReadyState = 4
     
    Application.Wait (Now + #12:00:03 AM#)
    
    Set allhyperlinks = objie.Document.getElementsByTagName("A")
    For Each hyper_link In allhyperlinks
    If hyper_link.innerText = "Post an Ad to this section »" Then
    hyper_link.Click
    End If
    Next
    
    Do
    DoEvents
    Loop Until objie.ReadyState = 4
    
    Application.Wait (Now + #12:00:01 AM#)
    y = InputBox("In one word what do you want to post")
    Sheets(2).Select
    Columns("B:B").Select
        Selection.Find(What:=y, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Select
     
     ActiveCell.Offset(0, -1).Range("A1").Select
     y = Selection.Value
     
    
    objie.Navigate ("https://www.ksl.com/index.php?nid=640&form_3=40&form_4=" & y)
    Application.Wait (Now + #12:00:01 AM#)
    Do
    DoEvents
    Loop Until objie.ReadyState = 4
    Call objie.Document.getElementById("6").setAttribute("value", "150")
    Call objie.Document.getElementById("8").setAttribute("value", "150")
    Call objie.Document.getElementById("136").setAttribute("value", "sale")
    Call objie.Document.getElementById("135").setAttribute("value", "1")
    Call objie.Document.getElementById("9").setAttribute("value", "150")
    Call objie.Document.forms(1).submit
     
    Do
    DoEvents
    Loop Until objie.ReadyState = 4
     
    
    Application.Wait (Now + #12:00:01 AM#)
     
    
    Call objie.Document.getElementById("11").setAttribute("value", Range("display").Value)
    
    Call objie.Document.getElementById("12").setAttribute("value", Range("email").Value)
    Call objie.Document.getElementById("13").setAttribute("value", Range("email").Value)
    
    Call objie.Document.getElementById("73_a").setAttribute("value", "801")
    Call objie.Document.getElementById("73_b").setAttribute("value", "205")
    Call objie.Document.getElementById("73_c").setAttribute("value", "2535")
    Call objie.Document.forms(1).submit
     
    Do
    DoEvents
    Loop Until objie.ReadyState = 4
     
    
    Application.Wait (Now + #12:00:01 AM#)
    
     
    'Call objie.Document.forms(2).submit
    Call objie.Document.getElementById("142").Click
    Application.Wait (Now + #12:00:01 AM#)
    '****************this section pulls up a window to attach a Picture of the item that is being posted.  I need to know how to get that window to populate. it seems to stop my code from running until I pick an option
     
    End Sub

  4. #4
    VBAX Regular
    Joined
    Sep 2013
    Posts
    37
    Location
    I know how to get the path of the file, but plugging it into that window makes things really hard. because it doesn't seem to be an internet window. also here is the source code for the element I am working with,

    HTML Code:
    <div class="element">
           <div id="u-142" class="photos">
            </div>
        <form id="f-142" method="post" enctype="multipart/form-data" action="/resources/form/upload.php" onsubmit="start_upload(142)">
        <input type="hidden" name="nid" value="640">
        <input type="hidden" name="sid" value="4516794">
        <input type="hidden" name="fid" value="779079">
        <input type="hidden" name="source" value="airlock">
        <input type="hidden" name="aid" value="63513691">
        <label for="142" class="iLabel">File:</label>
                <input type="hidden" name="MAX_FILE_SIZE" value="10000000">
        <input id="142" name="142" type="file" class="boxOk"><br>
        </form></div>

  5. #5
    VBAX Regular
    Joined
    Sep 2013
    Posts
    37
    Location
    one last thing to add is this piece of code that I found online saying to search for the window, but I don't understand how it works... functions are kind of my weak point. here is the VB code

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Sub Sample()
        Dim Ret
        Ret = FindWindow(vbNullString, "Choose File To Upload")
        If Ret <> 0 Then
            MsgBox "File upload window Found"
        Else
            MsgBox "File upload window Not Found"
        End If
    End Sub

Tags for this Thread

Posting Permissions

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