Excel Sheet to Word with vba

gumstic

New Member
Joined
Mar 8, 2020
Messages
1
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hi

I'm trying to copy an excel sheet over to a Word document via VBA.

I managed to get it all done but ALL sheets tag along.

VBA Code:
Sub PasteToWord()
    Dim appWord         As Word.Application
     
    Set appWord = CreateObject("Word.Application")
    appWord.Visible = True
     '  Change the range to suit your needs. See the How to Use for this code
    Worksheets("Spectrum1").Range("A1:J44").Copy
    appWord.Documents.Add
    appWord.Selection.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, _
                      Placement:=wdInLine, _
                      DisplayAsIcon:=False
  
    Application.CutCopyMode = False
    Set appWord = Nothing
End Sub

Any advice how I can copy ONLY the selected worksheet without others tagging along?

Thank you,
Andreas
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I ran your code and it worked normally for me. Only the data in range "A1:J44" on sheet "Spectrum1" was copied to the new word document
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top