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
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