CaliforniaDreamin
New Member
- Joined
- Jul 20, 2011
- Messages
- 2
New to VBA programming here and having a little trouble when trying to run a macro in Excel that pastes cells into Word on XP. It works fine in 07 and 10 versions of Office, but when it's run in XP there's an error because the Office 10 Word Object Library is not available on XP. Here's my code, thanks in advance for any help.
Sub CopyPaste()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Add
' Select range you want to export
Range("B12:C40").Copy
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteText, _
Placement:=wdInLine, DisplayAsIcon:=False
' Select all, format paragraph
WordApp.Selection.WholeStory
WordApp.Selection.ParagraphFormat.Space1
' Arial10
WordApp.Selection.WholeStory
WordApp.Selection.Font.Name = "Arial"
WordApp.Selection.Font.Size = 10
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub
Sub CopyPaste()
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
Set WordDoc = WordApp.Documents.Add
' Select range you want to export
Range("B12:C40").Copy
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteText, _
Placement:=wdInLine, DisplayAsIcon:=False
' Select all, format paragraph
WordApp.Selection.WholeStory
WordApp.Selection.ParagraphFormat.Space1
' Arial10
WordApp.Selection.WholeStory
WordApp.Selection.Font.Name = "Arial"
WordApp.Selection.Font.Size = 10
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub