Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

mdaiber614

Programmer
May 25, 2018
3
US
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 = "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
 
Hi,

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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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?
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top