Previous post seened to fail, probably my title
Can anyone help with this, im trying to use excel to open a word document add a line of text and then save it with a different name
Im most of the way there but cant figure out the save as bit
any help greatfully appreciated
Gibbo
Option Explicit
Sub openWordPlease()
' dont forget to set a ref to word object library
Dim wordApp As Object
Dim wordFile As Object
Dim myFile As String
Dim Rename As String
myFile = ThisWorkbook.Path & "\Test.doc"
Rename = "Test" & Now() & ". Doc"
Set wordApp = CreateObject("Word.Application")
wordApp.Visible = True
Set wordFile = wordApp.Documents.Open(myFile)
On Error GoTo 0
If wordFile Is Nothing Then
MsgBox "File is not found!", vbInformation, "ERROR"
GoTo quickEnd
End If
With wordFile
.Range.Text = Range("A1").Value
.SaveAs ThisWorkbook.Path & Rename <<< My Error
End With
'wordApp.Quit
quickEnd:
Set wordFile = Nothing
Set wordApp = Nothing
End Sub