Hi,
I have some basic code that in Mac opens a word doc from excel and then copies some data and pastes it into word... this was working fine last week with no issues... this week there were times it would not open word properly and then the data would not copy over even though the code said "Completed"... today it will not run at all... i am getting the error "'5863': 'Application' is not a method for the code line "oWord.Application" in the paste to word section... please can someone look at my code and see what is wrong? i added the Applciation.wait and DoEvents to try to get it to open correctly but its not working...
I have some basic code that in Mac opens a word doc from excel and then copies some data and pastes it into word... this was working fine last week with no issues... this week there were times it would not open word properly and then the data would not copy over even though the code said "Completed"... today it will not run at all... i am getting the error "'5863': 'Application' is not a method for the code line "oWord.Application" in the paste to word section... please can someone look at my code and see what is wrong? i added the Applciation.wait and DoEvents to try to get it to open correctly but its not working...
VBA Code:
Sub CopyToWord()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Create Word Doc
Dim oWord As Object
Application.Wait (10)
DoEvents
Set oWord = CreateObject(Class:=("Word.application"))
Application.Wait (10)
DoEvents
oWord.Visible = True
oWord.Activate
Application.Wait (10)
DoEvents
Dim oDoc
Application.Wait (10)
DoEvents
Set oDoc = oWord.Documents.Add
'Copy To Word
Sheet23.Select
Range("Print_Area21").CopyPicture
oWord.Application
oWord.Application.Selection.Paste.Special Link:=False, DataType:=15, _
DisplayAsIcon:=False
oWord.Selection.TypeParagraph
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''End Message
MsgBox ("Compied to Word")
End Sub