×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Macro to Copy Text from IE Browser and Paste in MS Word

Macro to Copy Text from IE Browser and Paste in MS Word

Macro to Copy Text from IE Browser and Paste in MS Word

(OP)
I am currently developing a macro for attachmate extra!. First the report is run in attachmate using send keys, then the macro waits for an email to show up in Outlook saying that the report is complete, and copies the URL from Outlook. All of this is complete and working. I need to develop code to copy all of the text in the browser and paste into a word document. I have tried the following code, and it works for most reports; however, for one longer report, it causes the macro editor to crash. Thinking about maybe using parsing, but I am not quite sure how to get that to work here. Any help would be greatly appreciated!!


Dim HTML As Object
Dim URL As String
Dim MSWORD As Object
Dim objDOC As Object
Dim ReportText As String

Set HTML = CreateObject("MSXML2.XMLHTTP60")
URL = "www.example.com"
Set MSWORD = CreateObject("Word.Applications.8")
Set objDOC = MSWORD.Documents.Add

HTML.Open "GET", URL, False
HTML.Send
ReportText = HTML.responseText
objDOC.Content.InsertAfter ReportText

RE: Macro to Copy Text from IE Browser and Paste in MS Word

Hi,

Quote:

it causes the macro editor to crash.

Are you using the Attachmate!Extra VB Editor, the Yugo of editors, or the Word VBA Editor, a Cadillac by comparison? I would ALWAYS opt for the latter. Never did any screen scraping to Word, but lots to Excel. NEVER used the Extra VB editor!

Actually interested that you’re using a terminal emulator to access the internet. Always used a terminal emulator to emulate a 3270 terminal interfacing an IBM mainframe.

I suppose your Extra HELP has all the screen manipulation commands for the type of terminal (HTML?) you’re emulating. But since it seems to be a capacity issue, (“for one longer report, it causes the macro editor to crash”) maybe a different editor would not crash.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Macro to Copy Text from IE Browser and Paste in MS Word

(OP)
I am using Attachmate VB editor, because that is the most convenient way for the person running the report to use the macro. Do you think it’s possible to get the text to word in another way?

RE: Macro to Copy Text from IE Browser and Paste in MS Word

I never wrote Extra applications for others’ use. People were looking for data from the mainframe based on a list of items and I ALWAYS ran my screen scrapes from an Excel list in Excel VBA and returnd to them a corresponding table of data from the mainframe in Excel. Extra VB was too klunky.

Your application is ending up with a Word document. Just a suggestion.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Macro to Copy Text from IE Browser and Paste in MS Word

(OP)
Okay so I took your advice and it worked great! Thank you so much,

BUT...

I tried to get my coworker to try running the report with the macro as well, and his isn’t working. It cannot connect to the “active session” in Extra! Attachmate.

Any thoughts?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close