Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Copy from Excel to Word

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Copy from Excel to Word

In message om of Mon,
26 Sep 2011 18:47:12 in microsoft.public.excel.programming, KP
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Copy from Excel to Word

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" skrev i en meddelelse
...
In message om of Mon,
26 Sep 2011 18:47:12 in microsoft.public.excel.programming, KP
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy from excel to word Robin Excel Programming 4 November 12th 09 05:56 AM
Copy from Word to Excel Miffed Excel Worksheet Functions 2 August 17th 07 04:22 PM
copy excel to word [email protected] Excel Programming 8 July 10th 07 01:57 AM
Copy from Word to Excel, and retain indent, plus word wrap Eric Excel Discussion (Misc queries) 1 March 9th 07 03:15 AM
search for a specific word and copy the word and the preceeding words until a comma DHANANJAY Excel Programming 12 December 31st 05 12:53 PM


All times are GMT +1. The time now is 12:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"