vba format size in Word

Wooly

New Member
Joined
May 10, 2018
Messages
7
hello, I'm using the following codes to copy from Excel to Word. But the table in Word is really wide. What kind of codes do I need to minimize the table when they get copied over? Thanks


Sub export_excel_to_word()
Set obj = CreateObject("Word.Application")
obj.Visible = True
Set newObj = obj.Documents.Add
ActiveSheet.Range("A3:c40").Copy
newObj.Range.Paste
Application.CutCopyMode = False
obj.Activate
newObj.SaveAs Filename:=Application.ActiveWorkbook.Path & "" & ActiveSheet.Name
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
You might try:
Code:
Sub Export_Excel_to_Word()
Dim wdApp As Object, wdDoc As Object
Set wdApp = CreateObject("Word.Application")
With wdApp
  .Visible = True
  Set wdDoc = .Documents.Add
  ActiveSheet.Range("A3:c40").Copy
  With wdDoc
    .Range.PasteExcelTable False, False, True
    Application.CutCopyMode = False
    .SaveAs Application.ActiveWorkbook.Path & "\" & ActiveSheet.Name & ".docx", 12, , , False
  End With
  .Activate
End With
Set wdDoc = Nothing: Set wdApp = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,762
Messages
6,174,354
Members
452,558
Latest member
jswan83

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