PC Review


Reply
Thread Tools Rate Thread

Copy from Excel to Word

 
 
KP
Guest
Posts: n/a
 
      26th Sep 2011
Hi,

Can someone help with a macro doing the following:

1. Copy a range from Excel sheet1 (e.g. A1:F30)
2. Open Word - new document
3. Paste the copied range to Word document
4. Close excel workbook without save
5. Save as dialogue box for created Word document

Regards,
Kaj Pedersen


 
Reply With Quote
 
 
 
 
Walter Briscoe
Guest
Posts: n/a
 
      26th Sep 2011
In message <4e80ac95$0$22714$c3e8da3$(E-Mail Removed)> of Mon,
26 Sep 2011 18:47:12 in microsoft.public.excel.programming, KP
<none@?.?.invalid> writes
>Hi,
>
>Can someone help with a macro doing the following:
>
>1. Copy a range from Excel sheet1 (e.g. A1:F30)
>2. Open Word - new document
>3. Paste the copied range to Word document
>4. Close excel workbook without save
>5. Save as dialogue box for created Word document


What have you tried?

1) I would try recording a macro, in word, which does what you want in
word.
2) Then record a macro to copy a given range to the clipboard.

3) You will need some code to start Word from an Excel macro.
Something like:

Dim Docs As Word.Application

Set Docs = CreateObject("Word.Application"): Docs.Visible = True
With Docs
.Documents.Open Filename:=foo
.Documents.Item(1).SaveAs Filename:=bar
End With

N.B. Dim Docs As Word.Application uses early binding.
If it fails for you, try Dim Docs as Object.

You probably want a method other than Open for your file.
Use Help in the Word VBE (Visual Basic Editor) to see what is available.

You then glue 1, 2, and 3 together and should be in business.
--
Walter Briscoe
 
Reply With Quote
 
KP
Guest
Posts: n/a
 
      27th Sep 2011
Thank you very much.

This hint from you helped me a lot:

"N.B. Dim Docs As Word.Application uses early binding.
If it fails for you, try Dim Docs as Object."

Now I think I will succeed.

Regards
Kaj Pedersen


"Walter Briscoe" <(E-Mail Removed)> skrev i en meddelelse
news:v3$(E-Mail Removed)...
> In message <4e80ac95$0$22714$c3e8da3$(E-Mail Removed)> of Mon,
> 26 Sep 2011 18:47:12 in microsoft.public.excel.programming, KP
> <none@?.?.invalid> writes
>>Hi,
>>
>>Can someone help with a macro doing the following:
>>
>>1. Copy a range from Excel sheet1 (e.g. A1:F30)
>>2. Open Word - new document
>>3. Paste the copied range to Word document
>>4. Close excel workbook without save
>>5. Save as dialogue box for created Word document

>
> What have you tried?
>
> 1) I would try recording a macro, in word, which does what you want in
> word.
> 2) Then record a macro to copy a given range to the clipboard.
>
> 3) You will need some code to start Word from an Excel macro.
> Something like:
>
> Dim Docs As Word.Application
>
> Set Docs = CreateObject("Word.Application"): Docs.Visible = True
> With Docs
> .Documents.Open Filename:=foo
> .Documents.Item(1).SaveAs Filename:=bar
> End With
>
> N.B. Dim Docs As Word.Application uses early binding.
> If it fails for you, try Dim Docs as Object.
>
> You probably want a method other than Open for your file.
> Use Help in the Word VBE (Visual Basic Editor) to see what is available.
>
> You then glue 1, 2, and 3 together and should be in business.
> --
> Walter Briscoe



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel failed to copy properly HTML Table had to copy 1st to word T John Doe Microsoft Excel Crashes 1 3rd Dec 2009 07:44 AM
How to copy Excel chart to Word so I can move it around in Word NonTechie Microsoft Word Document Management 7 11th Oct 2009 05:53 PM
Word & Excel 2007 Copy from Excel into word doc =?Utf-8?B?TWFyaw==?= Microsoft Word Document Management 4 8th May 2008 11:00 PM
Copy from Word to Excel, and retain indent, plus word wrap =?Utf-8?B?RXJpYw==?= Microsoft Excel Misc 1 9th Mar 2007 03:15 AM
MS WORD 2000 - Macro to copy spesific lines into excel/word ChaozFear Windows XP 0 20th Sep 2005 09:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:22 AM.