I have written the following code on a computer using Office 2007 which opens a new Word document and pastes some data from the excel document. However when I attempted to use the spreadsheet on another computer with Office 2003 installed I get a "Library not registered" error:
Sub PasteToWord()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim PupilName As String
Set wrdApp = New Word.Application
Set wrdDoc = wrdApp.Documents.Add(Template:="C:\Swimming\Template")
wrdApp.Visible = True
PupilName = getName()
Range("B195").Select
Selection.Copy
With wrdDoc
.Content.Paste
.SaveAs ("C:\Swimming\" + PupilName + " Targets.doc")
End With
End Sub
I have looked at the VBA references and the new version has Microsoft Word 12.0 Object Library ticked and the older version has Microsoft Word 11.0 Object Library ticked.
Can someone please help with the above code so that it will work on both computers.
Many thanks,
Paul