- Sub RangeToDocument()
- ' Set a VBE reference to Microsoft Word Object Library
- Dim WDApp As Word.Application
- Dim WDDoc As Word.Document
- ' Make sure a range is selected
- If Not TypeName(Selection) = "Range" Then
- MsgBox "Please select a worksheet range and try again.", vbExclamation, _
- "No Range Selected"
- Else
- ' Reference existing instance of Word
- Set WDApp = GetObject(, "Word.Application")
- ' Reference active document
- Set WDDoc = WDApp.ActiveDocument
- ' Reference active slide
- ' Copy the range
- Selection.Copy
- ' Paste the range
- WDApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF, _
- Placement:= wdInLine, DisplayAsIcon:=False
- ' Clean up
- Set WDDoc = Nothing
- Set WDApp = Nothing
- End If
- End Sub
来源: http://www.phpxs.com/code/1008858/