Results 1 to 6 of 6

Thread: Is this possible?

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    2

    Is this possible?

    Hi Guys,

    My company has had a web based thingy developed which shows us reports. Its very handy and definitely more efficient than previous methods. Sometimes however we have to run lots of reports, so I sit in front of the computer and change names (from a drop down), then press the print button, rinse, repeat.

    From my point of view, computers were designed so that people don't have to do this. As things stand, I'm aware that I'm probably posting on the wrong forum, but all my previous coding has been in VB 6 (Excel apps - I work in Finance). Some of them have got pretty convoluted so I'm fairly competent. I would like to be able to write something (preferably triggered via a button in an excel sheet) which gets hold of our report doohickey, fills in the fields the way I want, then goes through a list I provide printing the reports. I want to know if this is possible. Sadly the report thingymagjig was developed by outside consultants, so I don't know if we have access to the source code.

    Can this be done?

    Thanks,
    Simon

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Is this possible?

    Quote Originally Posted by Quafadas
    Hi Guys,
    From my point of view, computers were designed so that people don't have to do this.

    Can this be done?

    Thanks,
    Simon
    Welcome to VBforums Quafadas.

    Yes its called Mail Merge, do a search on here for mail merge and mailmerge.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    2

    Re: Is this possible?

    Hi Keith,

    Thanks for the response, but can Mail merge really do that?

    I've got to go to the website, fill in a few boxes and dropdowns, then click 'go', wait for the website to go away and query the database, render the report, and then print it. Lots of times...

    the following code

    Private Sub Command1_Click()

    Dim shellWins As SHDocVw.ShellWindows
    Dim explorer As SHDocVw.InternetExplorer

    'Get references to all explorer windows.
    Set shellWins = New SHDocVw.ShellWindows

    'iterate thriough them all
    For Each explorer In shellWins

    'Point it to report manager
    explorer.Navigate ("")

    'Check the URL
    Debug.Print explorer.LocationURL
    Next

    'Get rid of everything
    Set shellWins = Nothing
    Set explorer = Nothing

    End Sub

    Gets me a handle on all the versions of IE I have open, and I can send it to the webpage I want, however I'm stumped about how to fill the fields in. How do I point at them?!?

  4. #4
    Member
    Join Date
    Dec 2007
    Posts
    57

    Re: Is this possible?

    Hi Simon,

    A 'cheap-and-chearful' approach might be to use AppActivate() to select IE and then a bunch of SendKeys() calls. You can use SendKeys("{TAB}") to navigate through different text-fields etc.

    It's really low-tech but might do the job for you. Otherwise; personally I've never used SHDocVw but there might be a way to iterate through the HTML Document Object Model and set values & execute the form that way...

    reinholdmesner

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Is this possible?

    One way of doing it is to load the webpage into a WebBrowser control. (You should know the names and types of elements the page beforehand.) You can include a reference to the Microsoft HTML Object Library in your app, which gives you access to the HTMLDocument and HTMLInputElement objects. With this, you can programatically manipulate the elements (enter text into a textbox, choose an item from a dropdown, click a button, etc.)
    "It's cold gin time again ..."

    Check out my website here.

  6. #6
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Indiana
    Posts
    295

    Re: Is this possible?

    I wouldn't do it using VB6.

    Go to AutoItScript.com and download their free scripting program. It's quite good. It's very similar to VisualBasic and you'll probably catch on quick on how to code it.

    It will open web pages for you, click web page buttons, drop downs, etc. Will write to the web page as needed.

    If necessary you could incorporate to interact with a VB6 program of some sorts. For example, I have a VB6 program, and an AutoIt script file. The script file opens web pages, reads things off and passes it to the VB program which analyzes the data, then sends information back to the script file which may or may not process the web page somehow, depending on the analysis.
    Last edited by Caskbill; Dec 19th, 2007 at 10:38 PM.

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