matttclark
Board Regular
- Joined
- Jan 13, 2011
- Messages
- 100
Hi I am having a problem that is driving me nuts. I have not worked a lot with binding to other apps but I have searched and searched and tried different suggestions/variants to no avail, would GREATLY appreciate any help.
I tested the following code natively (without the added binding) in MS Word and it works fine, however when I try to call it from Excel, I can not get it to work. It executes, a new Word fiel is opened, the data is pasted in and I get no errors, but it does not replace anything in MS Word.
What am I doing wrong?? Using Office 2007
Thanks much! (very , very much)
I tested the following code natively (without the added binding) in MS Word and it works fine, however when I try to call it from Excel, I can not get it to work. It executes, a new Word fiel is opened, the data is pasted in and I get no errors, but it does not replace anything in MS Word.
What am I doing wrong?? Using Office 2007
Thanks much! (very , very much)
Code:
Sub minitest3()
Dim appWD As Object 'Word.Application
' Create a new instance of Word & make it visible
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
'add new doc, paste data from clipboard
appWD.documents.Add
appWD.Selection.Paste
'NO ERRORS BUT NOTHING GETS REPLACED
Set myRange = appWD.ActiveDocument.Content
myRange.Find.Execute FindText:="^lGrade: ", _
ReplaceWith:="^t", Replace:=wdReplaceAll
Set appWD = Nothing
MsgBox "done"
End Sub