Results 1 to 2 of 2

Thread: Copying text from Word document onto a webpage line by line

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    1

    Copying text from Word document onto a webpage line by line

    Hey there-

    I'm a pretty big VBA newbie, but I'm trying my luck at making a macro for my office. The goal of it is to take text from our engineering change notices and copy and paste into our online database. This would seem like an easy enough task to do without having to go through the trouble of making a macro, but the problem is that our online database requires the text to be copied in half-life by half-line (a line being the width of one line of a Word document). This is very tedious, taking about 4-5 minutes, and when we're doing a hundreds of ECN's a week, it can add up. So I'm looking into putting together a macro to automate the process.

    Thus far, I have been able to open up the webpage, but my macro gives me the error "Run-time error '-2147417848 (80010108)': Automation error The object invoked has disconnected from its clients" for the line

    Do While IE.ReadyState < 4: DoEvents: Loop

    Here is the code thus far

    Code:
    Sub ECNCOPY()
    '
    ' ECNCOPY Macro
    '
    '
    
    
    ' open IE and navigate to CINCOM
    
    Dim IE As Object
    Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True
    IE.Navigate "http://controlprdctl/Control1600/default.htm"
    
    
    'give time for webpage to load
    
    
    Do While IE.ReadyState < 4: DoEvents: Loop
    
    'set variable for text box and put in ECNTXM
    
    Dim ieElement As Object
    
    
    Set ieElement = IE.Document.getElementByID("txtQuickFunction")
    ieElement.Value = "ECNTXM"
    
    
    
    
    
    
    
    End Sub
    Thank you in advance for any advice you might be able to provide.

    Matt

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Copying text from Word document onto a webpage line by line

    try like
    Code:
    do until ie.readystate = 4: doevents: loop
    ' or 
    do while ie.busy: doevents: loop
    if you still get the same error, then maybe ie is crashing when trying to open the page, as no one can test the page it is hard to guess
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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