?
Solved

Using a macro to copy a cell to a field on a web page

Posted on 2011-09-17
7
Medium Priority
?
152 Views
Last Modified: 2012-05-12
Hello,

I would  like to create a macro to copy data from a group of cells to a group of fields on a web page. My company has a web site that we can go to, create a new flyer, input about 15 data fields and then print the flyer to hand out. I have a spread sheet that calculates the data for me. Now I want to copy the data one cell at a time and past it to the web site one field at a time. I created a macro by recording key strokes (ctrl+c alt+tab ctrl+v tab ctrl+c etc...) just the way I would do it manually but it doesn't work. It won't switch over to the web page that I have open. Is there a way to do this?
Thanks,
Tim
0
Comment
Question by:TimJar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 34

Expert Comment

by:Norie
ID: 36554869
Tim

One way you can do this by automating IE.

It should be quite straightforward, something like this.

1 Navigate to page.

2 Grab references to the data fields on the page.

3 Put the values from Excel into the data fields

4 Submit the page if required.

The individual steps would need to be refined of course but that's the basics.
0
 

Author Comment

by:TimJar
ID: 36554913
How would you do step 2. I can do it manually like this:

1. Select the first field in the page
2. alt+tab to go to the .xls file
3. select the first cell
4. ctrl+c
5. al+tab to go back
6. ctrl+v
7. tab to next field
and so on
0
 
LVL 34

Expert Comment

by:Norie
ID: 36554949
It's hard to be specific as it really depends on the page and how it's designed.

It also depends on the data in Excel.

With the approach I'm suggesting there wouldn't be any tabbing/selecting.


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TimJar
ID: 36554964
I don't know much about automating IE. Can you tell me what I should be researching?
0
 
LVL 34

Expert Comment

by:Norie
ID: 36554973
I don't know where you would research it.

If you can post the URL I could probably post some code.
0
 

Author Comment

by:TimJar
ID: 36555009
I think you have to be on our VPN to access it but here is the URL

http://www.cgxsolutions.com/idesign/index.asp
0
 
LVL 34

Accepted Solution

by:
Norie earned 2000 total points
ID: 36555050
This is how you could do the login using VBA, it takes the username and password from a worksheet.
Option Explicit

Sub LogIn()
Dim IE As Object
Dim doc As Object
Dim frm As Object
Dim inpUser As Object
Dim inpPword As Object
Dim strURL As String

    strURL = "http://www.cgxsolutions.com/idesign/index.asp"

    Set IE = CreateObject("InternetExplorer.Application")

    With IE

        .navigate strURL

        Do While .Busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
        .Visible = True

        Set doc = .document



        With doc

            Set frm = .forms(0)

            Set inpUser = .getelementbyid("frmUser") ' get reference to input for username

            inpUser.Value = Range("B1").Value ' put value from B1 into username

            Set inpPword = .getelementbyid("frmPWord") ' get reference to password input

            inpPword.Value = Range("B2").Value ' use value in B2 for password

        End With

        frm.submit ' now submit the login form

       ' .Quit ' Optional
    End With

End Sub

Open in new window

If you look at the source code of the page you want to fill out you will find the names/ids for the data fields.

Then you can use the same method this code uses to put values from the worksheet in the fields on the page.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question