PC Review


Reply
Thread Tools Rate Thread

copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro

 
 
Steven
Guest
Posts: n/a
 
      17th Oct 2005
Hi, there.

I really need this.
I need an excel macro copies multiple worksheets from a workbook. (A
workbook contains multiple worksheets), and paste onto a word
document.)
Please help me..I am so new at this excel macro, and have no idea to
start out.

 
Reply With Quote
 
 
 
 
Steven
Guest
Posts: n/a
 
      17th Oct 2005
I've found this code from microsoft.com. But it doesn't fit my needs
quite well.
I need it modified as macro finds active sheet and active cells from
each sheet.
This code copies from fixed location.

And I believe this code used if statement to check the system is PC or
MAC, but I will run this only on PC...need to get rid of that "if"
statement.

______________________________________________________________________

Sub PasteTableToWord()
Dim obj As Word.Application

Worksheets("sheet1").Activate 'Activate the worksheet
'Select the range of cells to copy
Worksheets("sheet1").Range("a1:c10").Copy

Set obj = CreateObject("Word.Application.9") 'Create a word object
obj.Visible = True 'Make Word visible
Set newDoc = obj.Documents.Add 'Create a new file.

'Determine if Microsoft Excel is running on the Macintosh or
Windows.
If (Application.OperatingSystem Like "*Mac*") Then
AppActivate "Microsoft word"
obj.Selection.PasteSpecial 'Paste data into Word

Else 'If Windows NT/95/3.x - paste data into Word
obj.Selection.PasteSpecial
End If
'Format table
obj.Selection.Tables(1).AutoFormat Format:=wdTableFormatGrid1
newDoc.SaveAs Filename:="C:\TestDoc.doc" 'Save the file
obj.Quit 'Quit Word
Set obj = Nothing 'Release object
End Sub

 
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
Done. Done. Done. msnyc07 Microsoft Excel Worksheet Functions 5 11th Feb 2010 11:46 PM
VBA / Macro for creating new worksheets and new columns from existing worksheets webby2006 Microsoft Excel Programming 3 25th Jul 2006 03:38 PM
open new Excel doc based on existing doc rdmacaulay via AccessMonster.com Microsoft Access VBA Modules 1 1st Mar 2006 07:25 AM
Macro to copy a word doc into an excel doc =?Utf-8?B?VGVl?= Microsoft Excel Misc 0 22nd Feb 2006 01:01 PM
Right click, create new Word doc creates Word plain text doc Paul Dolling Windows XP Basics 1 16th Aug 2003 04:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 AM.