Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to write VB code to paste several Excel ranges into a Word
document, as required by my employer. I'm able to do this satisfactorily using manual cut and paste (Office 2003), but when I automate it, I get "Run-time error 438: object doesn't support this method". I get this error whether I use Selection. or a variable Dim as Excel.Range or Word.Range or Object. I also get the error regardless of the type of paste I use. Pasted images aren't acceptable because the range may span several pages. Below is a code example. The errant command is flagged between '***** comments. Otherwise, the code runs as designed. The GetWordApp is from a previous post that I found useful (thanks!) I would appreciate any help you can give. Thanks, Dave in Madison Sub PrintToWordFile() Const fname = "C:\Test.doc" Const rname = "EntireBudget" Dim a As Excel.Range ' print range Dim g As Boolean ' gridlines flag Dim o As Object ' word application Dim w As Word.Document ' document within word application g = ActiveWindow.DisplayGridlines ActiveWindow.DisplayGridlines = False Set a = Range(rname) a.Copy GetWordApp o With o .Visible = True .Documents.Open Filename:=fname, ReadOnly:=False Set w = .Documents(fname) End With '***** a.PasteExcelTable _ LinkedToExcel:=False, _ WordFormatting:=False, _ RTF:=True '***** w.SaveAs "C:\Test.doc" o.Application.Quit ActiveWindow.DisplayGridlines = g Set w = Nothing Set o = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
2007 - link named excel range to word document | Excel Discussion (Misc queries) | |||
Inserting data into Word document by a range of dates from Excel spreadsheet | New Users to Excel | |||
Pasting Excel ('07) Range with Chart in Word ('07) | Charts and Charting in Excel | |||
Getting a range from Excel into a Word document | Excel Programming | |||
Pasting a Range to Word | Excel Programming |