I suggest the following
Sub Example()
Dim myDoc As String
Dim wdApp As Object
Dim oDoc As Object
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err Then
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
myDoc = "W:\ExampleLocation\Example UPLOAD " & Format(Date, "DD-MM-YYYY") & ".docx"
myAppl = "Word.Application"
'Check if Word Document exists and if not, create a new workbook and paste
If Not FileExists(myDoc) Then
Set oDoc = wdApp.documents.Add
oDoc.SaveAs myDoc
Else
Set oDoc = wdApp.documents.Open(myDoc)
End If
TakeScreenshot oDoc
PasteImagetoWord oDoc
Exit Sub
End Sub
Public Function FileExists(strFullName As String) As Boolean
'Graham Mayor
'strFullName is the name with path of the file to check
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFullName) Then
FileExists = True
Else
FileExists = False
End If
lbl_Exit:
Exit Function
End Function
You have not posted the code for the screen capture nor the image paste, but it is an easy matter to pass oDoc to the functions. e.g.
Sub PasteImageToWord(ByVal oDoc As Object)
Dim oRng As Object
Set oRng = oDoc.Range
oRng.collapse 0
oRng.Paste
lbl_exit:
Exit Sub
End Sub