# I need a way to copy webpage-\>MSWord

**URL:** https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926
**Category:** Factual Questions
**Created:** [August 27, 2009, 5:15pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926 "2009-08-27T17:15:34Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Chessic\_Sense](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Chessic\_Sense](https://boards.straightdope.com/u/Chessic_Sense)
#### Post date: [August 27, 2009, 5:15pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/1 "2009-08-27T17:15:34Z")

</div>

Part of my job is to copy pieces of data from different web pages into MS Word documents. The pages are always in the same exact format. At least ten of the data fields are always in the same place and always get copied to the same location. I’m tired of doing this manually.

Example: Let’s say I process order forms from customers for buckets of paint. For each order, I have a page with about 100 items on them. For the Word document I produce, I need to pull only 15 of those items (e.g. amount of paint, color and brand) off the web and into Word in specific locations of a template I already have built. The other 85 data points can be discarded. I then need to manually add in other data points from other sources, though I don’t see how that affects things.

What I’d _love_ would be a macro that says “Word, go to http://…com/85645786, go to line 36 of the page, copy characters 2 and 3, and paste it in line 56 of the .doc after character 8.” What’s the best way to build a program or macro that will do that? Please note that I’m pretty good with learning code, but I don’t have much knowledge of it already. I’d like the easiest method possible. If this is doable, it’ll save 30 man-hours a day and a lot of monotony.  
Thanks!

---

<div class="post-metadata">

### Author: ![Harmonious\_Discord](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@Harmonious\_Discord](https://boards.straightdope.com/u/Harmonious_Discord)
#### Post date: [August 27, 2009, 5:25pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/2 "2009-08-27T17:25:27Z")

</div>

Perhaps a program like this will work for you. [http://www.iopus.com/](http://www.iopus.com/)

---

<div class="post-metadata">

### Author: ![Chessic\_Sense](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Chessic\_Sense](https://boards.straightdope.com/u/Chessic_Sense)
#### Post date: [August 27, 2009, 5:30pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/3 "2009-08-27T17:30:52Z")

</div>

I can’t install a program on these computers, and we certainly can’t spend that kind of money.

---

<div class="post-metadata">

### Author: ![redtail23](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@redtail23](https://boards.straightdope.com/u/redtail23)
#### Post date: [August 27, 2009, 7:21pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/4 "2009-08-27T19:21:13Z")

</div>

You want some way to automatically perform a very complex task, that would save $300 per day (conservatively figured at $10 per hour for 30 hours per day), without installing any software and for free?

Good luck with that.

You’re probably not going to find a better solution that the one already offered. Unless you’re an expert programmer with the right development software, it’s highly unlikely that you’re going to manage to build your own.  
The other alternative is to find a better source/method for data acquisition than c&p from the web.

Is the data you’re pulling from _your_ webpages or someone else’s?

If it’s yours, I’d recommend going to your IT dept with a data request. That information is in a database somewhere, and it’s a hella lot easier to get data from a database than copy & paste from the web.

If it’s someone else’s data you’re using, then my best recommendation would be to set up a spreadsheet and store the data there for use, rather than c&p each time from the web. You’d have to figure out how often to check for updates, but if you’ve accurately represented the type of data, it wouldn’t be changing that often. Alternatively, if you’re pulling from manufacturer websites, contact them and ask for a datafile of their product data. They might laugh at you, but it’s worth a try.

---

<div class="post-metadata">

### Author: ![ZipperJJ](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zipperjj/32/211_2.png) [@ZipperJJ](https://boards.straightdope.com/u/ZipperJJ)
#### Post date: [August 27, 2009, 7:57pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/5 "2009-08-27T19:57:58Z")

</div>

I agree with redtail23.

If you really need something free, look around for something called a “Web Scraper” … something like [this](http://www.velocityscape.com/Products/WebScraperLite.aspx). Of course, you have to download it so I’m not sure how it would work for you…but you might also find some code out there so you can build your own Web Scraper and run it from your machine.

---

<div class="post-metadata">

### Author: ![Chessic\_Sense](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Chessic\_Sense](https://boards.straightdope.com/u/Chessic_Sense)
#### Post date: [August 27, 2009, 8:38pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/6 "2009-08-27T20:38:05Z")

</div>

> [@redtail23](#):
>
> Is the data you’re pulling from _your_ webpages or someone else’s?

It’s the government’s database. I have to go in and pull up records. I copy out parts of that record and stick it in Word. Then I do some other stuff to the Word document and send it out to be edited. I never revisit the same record, so putting it into a spreadsheet wouldn’t do me any good.

Could someone explain why this is a complex task? I plan to manually feed the program the correct URL. I just want it to return character 3486 and stick it in position 7248. If I can hyperlink with ease, I would have thought this would be pretty easy. No simple batch file or similar script could do this, you say?

ETA: The reason I can’t buy a program or install it is that the computers we use are classified. They don’t touch the NIPRNET and you can’t install anything without it going through a billion levels of bureaucracy first.

---

<div class="post-metadata">

### Author: ![Number](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/number/32/242_2.png) [@Number](https://boards.straightdope.com/u/Number)
#### Post date: [August 28, 2009, 1:16am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/7 "2009-08-28T01:16:43Z")

</div>

You can do this in VBScript without installing anything. Below is an example which scrapes a page’s raw HTML to a Word document.

Paste it into a text file with a .vbs extension and customize the value of the **strURL** variable with the page’s URL.

Getting the exact content you want and inserting it into the right spot in an existing document will take some fiddling.

Please don’t use this in any way which is contrary to the website’s terms of service or your IT department’s guidelines.

```auto

On Error Resume Next
 
strURL = "http://www.example.com"
strOutputFile = "output.doc"
 
Set objXmlHttp = CreateObject("Msxml2.XMLHttp")
objXmlHttp.Open "POST", strURL, False
objXmlHttp.onreadystatechange = getref("ReportStatus")
objXmlHttp.Send

Function ReportStatus()
    If (ObjXmlHttp.readyState = 4) Then
        strText = objXmlHttp.responseText
           
        Set objWord = CreateObject("Word.Application")
        objWord.Visible = True
        
        Set objDoc = objWord.Documents.Add()
        Set objSelection = objWord.Selection
        objSelection.TypeText(strText)
    End If
End Function

```

---

<div class="post-metadata">

### Author: ![Chessic\_Sense](https://avatars.discourse-cdn.com/v4/letter/c/7c8e57/32.png) [@Chessic\_Sense](https://boards.straightdope.com/u/Chessic_Sense)
#### Post date: [August 28, 2009, 8:27pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/8 "2009-08-28T20:27:48Z")

</div>

It’s that fiddling that I need help with. On the page, I have the option of exporting to an HTML view, ICML, TSV, PDF, KMZ, or saving as a file.

What about this: I can copy and past the code into Word to Notebook or something. Then have a macro scrape through that and pull out the stuff I want, placing it in the word document? If possible, it would suffice to have one that says “Go find this keyword, copy the word just after it, and place it here” Then I would just build 10 or 15 of these macros and execute them in order.

Pretty pretty please?

---

<div class="post-metadata">

### Author: ![Kimmy\_Gibbler](https://avatars.discourse-cdn.com/v4/letter/k/bbe5ce/32.png) [@Kimmy\_Gibbler](https://boards.straightdope.com/u/Kimmy_Gibbler)
#### Post date: [August 28, 2009, 9:28pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/9 "2009-08-28T21:28:29Z")

</div>

> [@Chessic\_Sense](#):
>
> At least ten of the data fields are always in the same place and always get copied to the same location. I’m tired of doing this manually.

Well, that’s the rub: how many data fields are you pulling, because even is it eleven such fields, where ten are in the same place all the time and the eleventh field’s place varies, I don’t see how this macro will save an appreciable amount of time (I take it that the marginal effort of copying ten more fields is negligible).

You say it’s a government database. You probably could request under FOIA and pay the government a small fee to run the query on their database (rather than copy it through the public-facing webpage) and send it to you on CD-ROM. I did this very thing with the DOL’s pension supervision records years ago. It cost like $35 or $350 or something, as I recall.

---

<div class="post-metadata">

### Author: ![MrSquishy](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@MrSquishy](https://boards.straightdope.com/u/MrSquishy)
#### Post date: [August 28, 2009, 10:18pm UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/10 "2009-08-28T22:18:45Z")

</div>

It looks like you might be able to DOM/XPath stuff in VBScript:

[http://techdos.com/content/view/77/69/](http://techdos.com/content/view/77/69/)

Note: I only skimmed the article, very briefly. But it might help.

---

<div class="post-metadata">

### Author: ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)
#### Post date: [August 29, 2009, 4:35am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/11 "2009-08-29T04:35:39Z")

</div>

I’d like to look more into this, but it’s hard without access to the data in question (or more importantly, the format that data is in). In some cases XPath would work better, in other cases regular expressions, and in yet other cases a simple substring.

I know the stuff you’re working on is classified, but could you modify the data (make it all burgers and milkshakes) while retaining the HTML layout and post the source somewhere? A declassified version of your Word template would be helpful too, though the HTML is more important.

---

<div class="post-metadata">

### Author: ![Oakminster](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@Oakminster](https://boards.straightdope.com/u/Oakminster)
#### Post date: [August 29, 2009, 4:43am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/12 "2009-08-29T04:43:02Z")

</div>

> [@Chessic\_Sense](#):
>
> ETA: The reason I can’t buy a program or install it is that the computers we use are classified. They don’t touch the NIPRNET and you can’t install anything without it going through a billion levels of bureaucracy first.

If you aren’t allowed to buy or install anything on a classified computer, your bosses prolly aren’t going to be happy about you programing it either.

---

<div class="post-metadata">

### Author: ![don\_t\_ask](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@don\_t\_ask](https://boards.straightdope.com/u/don_t_ask)
#### Post date: [August 29, 2009, 4:53am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/13 "2009-08-29T04:53:59Z")

</div>

I do similar things at work all the time with Excel. I have reports where the formatted report is one worksheet and the data for the report is pasted straight into other worksheets. So I export the data from one source as a text file, dump it in a raw data worksheet and the correct cell of the report worksheets says, for example =left(rawdata1!,2,6). I sometimes use vlookups for the purpose and have reports that are made up of 6 different sources. The end user only gets the formatted report and the template is saved.

---

<div class="post-metadata">

### Author: ![Alex\_Dubinsky](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@Alex\_Dubinsky](https://boards.straightdope.com/u/Alex_Dubinsky)
#### Post date: [August 29, 2009, 5:06am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/14 "2009-08-29T05:06:45Z")

</div>

> [@Chessic\_Sense](#):
>
> ETA: The reason I can’t buy a program or install it is that the computers we use are classified. They don’t touch the NIPRNET and you can’t install anything without it going through a billion levels of bureaucracy first.

I think you’re overlooking the spirit of it. Any Word macro can jeopardize your security, big time. (Used to be that half of viruses were in this form.) But if you don’t care, and you just don’t want it in your Add/Remove Programs, then you can have any old stand-alone executable made for you (or vbs macro, if you prefer). Programmers on a site like RentACoder will be happy to create one to your requirements for under (probably well under) $100. I’ve had the same done myself. It’s trivial for them, just be precise in what you want.

---

<div class="post-metadata">

### Author: ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)
#### Post date: [August 29, 2009, 5:28am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/15 "2009-08-29T05:28:19Z")

</div>

> [@Alex\_Dubinsky](#):
>
> I think you’re overlooking the spirit of it. Any Word macro can jeopardize your security, big time. (Used to be that half of viruses were in this form.) But if you don’t care, and you just don’t want it in your Add/Remove Programs, then you can have any old stand-alone executable made for you (or vbs macro, if you prefer). Programmers on a site like RentACoder will be happy to create one to your requirements for under (probably well under) $100. I’ve had the same done myself. It’s trivial for them, just be precise in what you want.

I think – or at least hope – that he’s trying to build a macro himself (with help from people here) so that he can see and understand the entirety of the source before running it.

I guess that could apply to purchased macros too, but not .exes.

---

<div class="post-metadata">

### Author: ![samclem](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@samclem](https://boards.straightdope.com/u/samclem)
#### Post date: [August 29, 2009, 11:14am UTC](https://boards.straightdope.com/t/i-need-a-way-to-copy-webpage-msword/507926/16 "2009-08-29T11:14:28Z")

</div>

> [@Chessic\_Sense](#):
>
> ETA: The reason I can’t buy a program or install it is that the computers we use are classified. They don’t touch the NIPRNET and you can’t install anything without it going through a billion levels of bureaucracy first.

Since you say you’re using classified computers, perhaps you need to go through those levels of bureaaucracy.

Closed.

**samclem** Moderator, General Questions
