+ Reply to Thread
Results 1 to 2 of 2

Macro copying from cells in Excel to text field in IE

Hybrid View

  1. #1
    Registered User
    Join Date
    09-09-2014
    Location
    Ann Arbor, Michigan
    MS-Off Ver
    Office 365
    Posts
    10

    Macro copying from cells in Excel to text field in IE

    I am trying to form a macro that copies a range of cells from an excel worksheet to a text field in internet explorer. I am able to get the macro to navigate to the text field that I want my cells to be copied to and I am even able to get something to copy to the text field. However, the result is as shown below:
    vbaOutputTextBox.png

    Below are the relevant sections of code that I have (the rest of the code in my macro takes me to the webpage and sets up the data in the cells to be copied):

    For i = 85 To 119
    If Cells(i, 2).Value <> "" Then
    Cells(j, 3).Value = Cells(i, 2).Value
    j = j + 1
    End If
    Next i
    K = "C85:C" & CStr(j - 1)
    Range(K).Select
    Selection.Copy
    ...
    ...
    ...
    ie.document.All.Item("draftText").Value = Sheets("IYM Calculation").Range(K)

    Does anyone have any advice or ideas on why this might not be working for me? Is this even possible?

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Macro copying from cells in Excel to text field in IE

    Selection.Copy is putting the entire cell object, including all its properties, into the paste buffer, so that's the object it's pasting into the text field. Try modifying the following for your code. I take no credit for it -- I found it by doing a search.

    Sub CopytoClipboard()
        ' Requires a reference to Microsoft Forms Object Library
        ' An easy way to do this is to add and then delete a form;
        ' the reference will persist
        With New DataObject
            .SetText ActiveCell.Value
            .PutInClipboard
        End With
    End Sub
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to paste a range of cells from excel to text field of a web page
    By Menaka in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-21-2013, 09:43 AM
  2. Replies: 0
    Last Post: 04-22-2013, 12:13 PM
  3. Replies: 1
    Last Post: 06-29-2012, 01:16 PM
  4. Copying Cells Which Appear More than Once in a Field
    By gtidey in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-31-2010, 11:56 AM

Tags for this Thread

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.6.0 RC 1