Open word doc and cut and paste 
Author Message
 Open word doc and cut and paste

For another project I am doing, I would like to be able to

a) open a word document from excel
b) copy some text across
c) let excel carry on when the document has been closed

For part b) I was going to put the text into the clipboard (this is
easy) and use SendKeys, but I can't see this being reliable.  I could
create is as a mail merge document, but this seems excessive - is there
an easier way

For a) and c) I am using something called ShellAndWait I picked up off
the net.  This is just basically the Shell command with a few APIs
around it which get various handles, and loop until the process dies,
but I'd prefer to use automation if this helps with my answer to b).

If I am to paste the text in rather than mailmerge, I take it I just
need chr(13)'s where I want the carriage returns to be (I am pulling
addresses from cells on a spreadsheet and want to print this as an
address label)
--
Mike



Tue, 16 Aug 2005 08:21:47 GMT  
 Open word doc and cut and paste
Hi Mike,

Start with the article "Control Word from Excel" at
http://www.mvps.org/word/FAQs/InterDev/ControlWordFromXL.htm

HTH


Quote:
> For another project I am doing, I would like to be able to

> a) open a word document from excel
> b) copy some text across
> c) let excel carry on when the document has been closed

> For part b) I was going to put the text into the clipboard (this is
> easy) and use SendKeys, but I can't see this being reliable.  I could
> create is as a mail merge document, but this seems excessive - is there
> an easier way

> For a) and c) I am using something called ShellAndWait I picked up off
> the net.  This is just basically the Shell command with a few APIs
> around it which get various handles, and loop until the process dies,
> but I'd prefer to use automation if this helps with my answer to b).

> If I am to paste the text in rather than mailmerge, I take it I just
> need chr(13)'s where I want the carriage returns to be (I am pulling
> addresses from cells on a spreadsheet and want to print this as an
> address label)
> --
> Mike



Sat, 20 Aug 2005 04:55:42 GMT  
 Open word doc and cut and paste
On Mon, 3 Mar 2003 at 15:55:42, Dave Lett (Dave Lett
Quote:

>Start with the article "Control Word from Excel" at
>http://www.mvps.org/word/FAQs/InterDev/ControlWordFromXL.htm

 >
Thanks - I am starting to make some progress.  It does say however to
add the code below....  If the sub is going to end, won't the variables
be discarded anyway.  I see people put this in, and don't really
understand why

'Make sure you release object references.
Set oWord = Nothing
Set oDoc = Nothing

--
Mike



Tue, 23 Aug 2005 07:13:52 GMT  
 Open word doc and cut and paste
Hi Mike,

Perhaps a programmer can chime in here (I'm a techncial writer), but my
understanding is that statements like these (Set oWord = Nothing) release
the memory location that the program used to create your object. So my
tidbits are
    1) this is a "clean up" practice
    2) this is standard practice
    3) this is good practice.

HTH


Quote:
> On Mon, 3 Mar 2003 at 15:55:42, Dave Lett (Dave Lett

> >Start with the article "Control Word from Excel" at
> >http://www.mvps.org/word/FAQs/InterDev/ControlWordFromXL.htm

> Thanks - I am starting to make some progress.  It does say however to
> add the code below....  If the sub is going to end, won't the variables
> be discarded anyway.  I see people put this in, and don't really
> understand why

> 'Make sure you release object references.
> Set oWord = Nothing
> Set oDoc = Nothing

> --
> Mike



Tue, 23 Aug 2005 21:48:19 GMT  
 Open word doc and cut and paste
On Fri, 7 Mar 2003 at 08:48:19, Dave Lett (Dave Lett
Quote:

>Hi Mike,

>Perhaps a programmer can chime in here (I'm a techncial writer), but my
>understanding is that statements like these (Set oWord = Nothing) release
>the memory location that the program used to create your object. So my
>tidbits are
>    1) this is a "clean up" practice
>    2) this is standard practice
>    3) this is good practice.

 >
Well all variables Dim'ed within the sub itself should be local, and as
such get discarded when the sub exits
--
Mike


Wed, 24 Aug 2005 01:36:07 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Cutting a full Word document and pasting it in another Word Document

2. Word 2000 Cut and Paste

3. Cutting And Pasting With VBA in Word

4. Open word 97 doc with doc name as variable

5. pasting a word doc into an email without losing paragraphing

6. Pasting Excel Charts into Word Doc

7. Woes = Excel Range to Word Doc paste = Guidance Please

8. Excel open .doc or word open .xls?

9. Printing multiple Word doc files without opening each in word

10. Auto close open doc when opening another doc

11. Pasting Range from Excel 2002 via VBA to Word causes a New Workbook to open

12. Opening a Word Doc from Access with File Name Stored in a Table

 

 
Powered by phpBB® Forum Software