I have this macro to copy data from Excel and paste into Word. I am trying to get the file picker to work but throws me an error. If no file is selected it works as expected, the macro ends. If a file is selected I get "run error 13, incompatible types" (or something like that in English) on the row marked below. Any ideas?
VBA Code:
Dim wb As Workbook
Dim wApp As Word.Application
Dim wDoc As Object
Dim wFileSelect As String
Set wb = ActiveWorkbook
Set wApp = CreateObject("Word.Application")
'Choose the target Word file
wFileSelect = Application.GetOpenFilename("Word-files,*.doc*", _
1, "Select Source File To Open", , False)
'if the user didn't select a file, exit sub
If wFileSelect = False Then '''ERROR HERE!
Set wApp = Nothing
Set wb = Nothing
Application.ScreenUpdating = True
Exit Sub
End If
' Open the word file
wApp.Visible = True
Documents.Open wFileSelect
Set wDoc = ActiveDocument