Questions

VBA Expert..urgent help

Tags:
+
0 Votes
Locked

VBA Expert..urgent help

fanku
****** Following code giving run time error 438 *** how to fix that error..pls help..its urgent

'Dim Cell As Range
Dim myWord As Object
Dim PathDocu As String

Set myWord = CreateObject("word.application")
'Set myWord = GetObject(, "Word.Application")

Set myWord = GetObject("g:\global\mahesh\offer letter.doc")
myWord.Application.Visible = True
myWord.Activate
'PathDocu = "G:\global\mahesh\"

With myWord
'Documents.Open (PathDocu & "offer letter.doc")
myWord.ActiveDocument.Bookmarks("date").Range.Text = Format(Date, "dd mmmm yyyy")
myWord.ActiveDocument.ActiveDocument.Bookmarks("firstname").Range.txt = Me.fname
myWord.ActiveDocument.Bookmarks("lname").Range.Text = Me.lname
myWord.ActiveDocument.Bookmarks("add1").Range.Text = Me.add1
myWord.ActiveDocument.Bookmarks("add2").Range.Text = Me.add2
myWord.ActiveDocument.Bookmarks("add3").Range.Text = Me.add3
myWord.ActiveDocument.Bookmarks("add4").Range.Text = Me.add4
myWord.ActiveDocument.Bookmarks("designation").Range.Text = Me.desig
myWord.ActiveDocument.Bookmarks("grade").Range.Text = Me.grade
myWord.ActiveDocument.Bookmarks("location").Range.Text = Me.location
myWord.ActiveDocument.Bookmarks("reportingto").Range.Text = Me.reporting
'If Me.Adresse <> "" Then myWord.ActiveDocument.Bookmarks("adresse").Range.Text = Me.Adresse
.Visible = True
End With

DoEvents
Set myWord = Nothing

On Error GoTo Err_Enveloppe_Click

Exit_Enveloppe_Click:
Exit Sub

Err_Enveloppe_Click:
MsgBox Err.Description
Resume Exit_Enveloppe_Click