Hi guys,
everytime I run this macro I will always get the Run-time error '438': Object doesn't support this property or method. Can someone help me debug this because I have no clue how to fix this?
If it can't be fixed, I'm basically trying to copy text from excel to word, use the replace function to reformat, and copy and paste the newly formatted text from word to excel.
Sub modulenter()
Dim appWD As Word.Application
Dim Name As String
Set appWD = CreateObject("Word.Application")
appWD.Visible = False
Sheets("Sheet1 (2)").Select
FinalRow = Range("F9999").End(xlUp).Row
For i = 2 To FinalRow
j = Sheets("MasterList").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("MasterList").Cells(j, 1).Value = Sheets("Sheet1 (2)").Cells(i, 3).Value
Sheets("Sheet1 (2)").Select
Cells(i, 6).Copy
' Tell Word to create a new document
appWD.Documents.Add
' Tell Word to paste the contents of the clipboard into the new document
appWD.Selection.Paste
' Save the new document with a sequential file name
appWD.Selection.Find.Replacement.ClearFormatting
With appWD.Selection.Find
.Text = "@"
.Replacement.Text = "^n"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
appWD.Selection.Find.Execute Replace:=wdReplaceAll
appWD.Selection.WholeStory
appWD.Selection.Cut
Sheets("Masterlist").Cells(j, 2).Selection.Paste
appWD.ActiveDocument.WholeStory
appWD.Selection.delete
appWD.ActiveDocument.Close
Next i
' Close the Word application
appWD.Quit
End Sub
Thanks!
Bookmarks