The problem is that
fDialog = Application.FileDialog(msoFileDialogFilePicker).Sh ow
does not return a file name, so you cannot use the fDialog result in
the Open method, which expects a String file name.
See my reply to your other post on this topic today, 4-Sept.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Thu, 3 Sep 2009 16:23:02 -0700, Sam
wrote:
Hi All,
I am getting a type mismatch error on this line:
Set doc = wdApp.Documents.Open(fDialog)
what might be the reason? Here is the whole code:
Dim wdApp As Object
Dim doc As Object
On Error Resume Next
Set wdApp = GetObject("C:\My Documents\Address.dotx", "Word.Application")
If Err.Number < 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Dim FName As String
fDialog = Application.FileDialog(msoFileDialogFilePicker).Sh ow
On Error Resume Next
Set doc = wdApp.Documents.Open(fDialog)
wdApp.ActiveDocument.Variables("Address").Value = Me.Address.Value
wdApp.ActiveDocument.Variables("City").Value = Me.City.Value
wdApp.ActiveDocument.Fields.Update
FName = "C:\My Documents\" & "Address" & ".doc"
wdApp.ActiveDocument.SaveAs FileName:=FName
wdApp.Visible = True
Set doc = Nothing
Set wdApp = Nothing
wApp.Quit
End Sub
Please help!
Thanks in advance