Link to home
Start Free TrialLog in
Avatar of SBFVAN
SBFVAN

asked on

Macro to insert selected paragraphs from webpage

Hi

This is to enhance the solution that was created here:
https://www.experts-exchange.com/questions/25646695/How-do-I-create-macro-to-copy-paragraphs-from-one-word-document-and-paste-it-in-a-new-one.html

I need to create a macro where a user will press a hotkey, then a prompt (form will look like "select-paragraph.jpg") will come up where they are to enter a number(s) to indicate which paragraphs they want inserted into their document.

The paragraphs will be coming from a word document (or local webpage) that resides on our server (paragraphs.doc).  As you can see in the paragraphs.doc file, there are numbers associated to the paragraphs.  So at the "Select Paragraph" prompt, they will enter "2,4,5", the macro will insert paragraphs 2,4 and 5.

 Paragraphs.doc
 User generated image
ASKER CERTIFIED SOLUTION
Avatar of lwebber
lwebber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SBFVAN
SBFVAN

ASKER

Hi Iwebber

Thanks for the answer.

Just curious, would it be possible to grab the paragraphs from a website.  I'd prefer for it to grab the paragraphs from an official webpage to minimize the potential for error as well as being up to date.

Please advise

Thanks

SBFVAN
No. AutoText has to live inside a Word template. To use a web page as a source, you would need to write some VBA code. This will be unpleasant, because the custom code has to know the internal formatting of the web page so that it can pick off what to you seem like obvious paragraphs. You could make your life easier if you have control over the formatting of the web page, and use tags with ID attributes like Para1, Para2, etc. But still, the VBA code is highly non-trivial. Word has to instantiate its own web browser, navigate to the page, parse the contents, grab the paragraph, etc. And after all that, you're not going to get stable formatting (unlike the AutoText approach).

How often do the contents change? You could simply distribute updated copies of the template to your users in a self-unpacking Zip file that copies the template into the user's Startup folder.
Avatar of SBFVAN

ASKER

Thanks