Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I want to copy a section of an excel sheet to a word document and save the word document. I have tried several senarios to no avail. My attempts do not recognize that the word document exists. What code do I use and do I need to do something special so that the excel workbook cooperates with word? Thank you, David -- eyecalibrate ------------------------------------------------------------------------ eyecalibrate's Profile: http://www.excelforum.com/member.php...fo&userid=6621 View this thread: http://www.excelforum.com/showthread...hreadid=497181 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Something like this:
Sub PrintToWordFile() Const fname = "C:\Test.doc" Const rname = "A1:B10" Dim a As Excel.Range Dim g As Boolean Dim o As Object Dim w As Word.Document Dim wdRng as Word.Range g = ActiveWindow.DisplayGridlines ActiveWindow.DisplayGridlines = False Set a = Range(rname) a.Copy set o = CreateObject("Word.Application") ' or if word is open ' GetObject(, "Word.Application") With o .Visible = True .Documents.Open Filename:=fname, ReadOnly:=False Set w = .Documents(fname) set wdRng = selection End With '***** ' PASTE TABLE WdRng.PasteSpecial Link:=False, _ DataType:=1, Placement:=0, _ DisplayAsIcon:=False '' 1 = wdPasteRTF, 0 = wdInLine '***** w.SaveAs "C:\Test.doc" o.Application.Quit ActiveWindow.DisplayGridlines = g Set w = Nothing Set o = Nothing End Sub -- Regards, Tom Ogilvy "eyecalibrate" wrote in message news:eyecalibrate.20x41b_1136055002.9873@excelforu m-nospam.com... I want to copy a section of an excel sheet to a word document and save the word document. I have tried several senarios to no avail. My attempts do not recognize that the word document exists. What code do I use and do I need to do something special so that the excel workbook cooperates with word? Thank you, David -- eyecalibrate ------------------------------------------------------------------------ eyecalibrate's Profile: http://www.excelforum.com/member.php...fo&userid=6621 View this thread: http://www.excelforum.com/showthread...hreadid=497181 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PASTE LINK option not available when I select PASTE SPECIAL to link an image in Excel to a Word document. | Links and Linking in Excel | |||
Can you save an excel spreadsheet to a word document or pdf? | Excel Discussion (Misc queries) | |||
How do I paste a Word document into an Excel cell | Excel Discussion (Misc queries) | |||
is it possible to save xls file to a word document like an attachm | Excel Discussion (Misc queries) | |||
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 | Excel Programming |