riduwanz
02-26-2005, 11:44 AM
Hi Everyone,
I hope to get some help with the codes below. There are some other codes that pass Excel filename value to this macro. The intention is to use the same filename (without the extension .xls) as the name of the Word file.
The error is during the Save As...it says invalid file name (I think it is due to the .XLS extension) Anybody can kindly advise?
Sub SaveNewWordFile(ByVal fileNameWord As String)
Dim appWord As Object
Dim fileWord As Object
Dim newWord As String
newWord = ThisWorkbook.Path & fileNameWord
Set appWord = CreateObject("Word.Application")
appWord.Visible = True
Set fileWord = appWord.Documents.Add
appWord.Selection.Paste
With wordFile
.SaveAs newWord
.Close
End With
Set fileWord = Nothing
Set appWord = Nothing
End Sub
:banghead:
Thanks in advance.
Rid
I hope to get some help with the codes below. There are some other codes that pass Excel filename value to this macro. The intention is to use the same filename (without the extension .xls) as the name of the Word file.
The error is during the Save As...it says invalid file name (I think it is due to the .XLS extension) Anybody can kindly advise?
Sub SaveNewWordFile(ByVal fileNameWord As String)
Dim appWord As Object
Dim fileWord As Object
Dim newWord As String
newWord = ThisWorkbook.Path & fileNameWord
Set appWord = CreateObject("Word.Application")
appWord.Visible = True
Set fileWord = appWord.Documents.Add
appWord.Selection.Paste
With wordFile
.SaveAs newWord
.Close
End With
Set fileWord = Nothing
Set appWord = Nothing
End Sub
:banghead:
Thanks in advance.
Rid