tektipuser88
Technical User
hi there,
have code below which used to work fine but suddenly not working... application errors and closes itself when it gets to the .find .text bit.
I've made sure i have a ref to word ojb lib.
i'm pulling my hair out as to why it won't work anymore.. any help, hints tips is most welcome!
thanks in advance!
Sub findAndPaste()
Dim aimaApp As Word.Application, targApp As Word.Application
Dim aimaDoc As Word.Document, targDoc As Word.Document
Dim searchString As String
Dim personApp As Word.Application
Set aimaApp = New Word.Application
With aimaApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
'open up current AIMA doc
'Set aimaDoc = aimaApp.Documents.Open("W:\Investor Services\AIMA Due Diligence\Auto AIMA\AIMA Questionnaire.doc")
Set aimaDoc = aimaApp.Documents.Open("C:\Hell.doc")
Set personApp = New Word.Application
With personApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set targDoc = personApp.Documents.Add
searchString = "hello"
aimaDoc.Activate
With aimaApp.Selection.Find
'app errors out here, if i put mouse over .text it says 'invalid procedure call or argument'!!
.Text = searchString
.Wrap = wdFindContinue
End With
aimaApp.Selection.Find.Execute
aimaApp.Selection.SelectRow
aimaApp.Selection.Copy
targDoc.Activate
personApp.Selection.PasteSpecial
personApp.Quit (False)
aimaApp.Quit (False)
End Sub
have code below which used to work fine but suddenly not working... application errors and closes itself when it gets to the .find .text bit.
I've made sure i have a ref to word ojb lib.
i'm pulling my hair out as to why it won't work anymore.. any help, hints tips is most welcome!
thanks in advance!
Sub findAndPaste()
Dim aimaApp As Word.Application, targApp As Word.Application
Dim aimaDoc As Word.Document, targDoc As Word.Document
Dim searchString As String
Dim personApp As Word.Application
Set aimaApp = New Word.Application
With aimaApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
'open up current AIMA doc
'Set aimaDoc = aimaApp.Documents.Open("W:\Investor Services\AIMA Due Diligence\Auto AIMA\AIMA Questionnaire.doc")
Set aimaDoc = aimaApp.Documents.Open("C:\Hell.doc")
Set personApp = New Word.Application
With personApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set targDoc = personApp.Documents.Add
searchString = "hello"
aimaDoc.Activate
With aimaApp.Selection.Find
'app errors out here, if i put mouse over .text it says 'invalid procedure call or argument'!!
.Text = searchString
.Wrap = wdFindContinue
End With
aimaApp.Selection.Find.Execute
aimaApp.Selection.SelectRow
aimaApp.Selection.Copy
targDoc.Activate
personApp.Selection.PasteSpecial
personApp.Quit (False)
aimaApp.Quit (False)
End Sub