Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-17
7
Medium Priority
?
155 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 35

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 35

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 35

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 35

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

618 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