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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,222,118
Messages
6,164,072
Members
451,870
Latest member
Nikhil excel

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