Creating a Word Doc from a Excel Worksheet

dbrull

Board Regular
Joined
Jun 25, 2002
Messages
71
I have a macro that copies a range from a table of data, and creates a word doc from it.
The problem is that the word doc ends up with the grid lines. I would just like it to have the borders on the cells i have selected on the excel worksheet.

how would i do this? Currently this is the paste command I have.

WdObj.Selection.Paste

Thanks in advance!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi!

Could I see the rest of the code for your macro, this is something I'm very interested in doing.

Did you try options...view...show gridlines(not checked)?

Just a thought.

Peace,
Corticus
 
Upvote 0
Yup sure did I think the lines are from the Word program.. not sure though

heres the complete code someone on this forum helped me with.

Sub WordUp()
Dim WdObj As Object, fname As String
fname = Sheets(1).[a1].Value
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False
Range("word").Copy
WdObj.documents.Add
WdObj.Selection.Paste
Application.CutCopyMode = False
If fname <> "" Then 'make sure fname is not blank
With WdObj
.ChangeFileOpenDirectory "c:Personal" 'save Dir
.ActiveDocument.SaveAs FileName:=fname & ".doc"
End With
Else:
MsgBox ("File not saved, naming range was botched, guess again.")
End If
With WdObj
.ActiveDocument.Close
.Quit
End With
Set WdObj = Nothing
End Sub
 
Upvote 0
Thanks sooo much,

I'm playing with the code now, I'll let you know if I have any luck...

Corticus
 
Upvote 0
This should do it,

Sub WordUp()

Dim WdObj As Object, fname As String
fname = Sheets(1).[a1].Value

Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False

Range("Word").Copy
WdObj.documents.Add

'this line specifies to paste special, as Unicode text
WdObj.Selection.PasteSpecial Link:=False, DataType:=20, Placement:= _
wdInLine, DisplayAsIcon:=False

Application.CutCopyMode = False
If fname<> "" Then 'make sure fname is not blank
With WdObj
.ChangeFileOpenDirectory "c:\Personal" 'save Dir
.ActiveDocument.SaveAs Filename:=fname & ".doc"
End With
Else:
MsgBox ("File not saved, naming range was botched, guess again.")
End If
With WdObj
.ActiveDocument.Close
.Quit
End With
Set WdObj = Nothing
End Sub

HTH,
Corticus
This message was edited by Corticus on 2002-08-29 11:48
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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