Public Function CreateWord(strDocuPath As String)
'function returns nothing, but I created this as a
'function so all those macro users out there could
'use it also.
'if no path is passed to function, exit - no further
'need to do anything
If IsNull(strDocuPath) Or strDocuPath = "" Then
Exit Function
End If
Dim dbs As Database
Dim objectWord As Object
Dim PrintResponse
Set dbs = CurrentDb
'create reference to Word Object
Set objectWord = CreateObject("Word.Application"
'Word Object is created - now let's fill it with data.
With objectWord
.Visible = True
.Documents.Open (strDocuPath)
'move to each bookmark, and insert correct text.
.ActiveDocument.Bookmarks("report".Select
.Selection.Text = (CStr(Forms!incident2!Report))
.ActiveDocument.Bookmarks("date".Select
.Selection.Text = (CStr(Forms!incident2!Date))
.ActiveDocument.Bookmarks("time".Select
.Selection.Text = (CStr(Forms!incident2!Time))
.ActiveDocument.Bookmarks("title".Select
.Selection.Text = (CStr(Forms!incident2!Title))
.ActiveDocument.Bookmarks("location".Select
.Selection.Text = (CStr(Forms!incident2!Location))
Range = Selection.Range
'** continue the ActiveDocument and Selection statements for each bookmark that you have on the Word Document **
Set objectWord = Nothing
End With
End Function
that is how i create it...i wan to save it so i can send the doc as attachment to email...i manage to send it...but the doc is empty...can anione help pls?thanks...
'function returns nothing, but I created this as a
'function so all those macro users out there could
'use it also.
'if no path is passed to function, exit - no further
'need to do anything
If IsNull(strDocuPath) Or strDocuPath = "" Then
Exit Function
End If
Dim dbs As Database
Dim objectWord As Object
Dim PrintResponse
Set dbs = CurrentDb
'create reference to Word Object
Set objectWord = CreateObject("Word.Application"
'Word Object is created - now let's fill it with data.
With objectWord
.Visible = True
.Documents.Open (strDocuPath)
'move to each bookmark, and insert correct text.
.ActiveDocument.Bookmarks("report".Select
.Selection.Text = (CStr(Forms!incident2!Report))
.ActiveDocument.Bookmarks("date".Select
.Selection.Text = (CStr(Forms!incident2!Date))
.ActiveDocument.Bookmarks("time".Select
.Selection.Text = (CStr(Forms!incident2!Time))
.ActiveDocument.Bookmarks("title".Select
.Selection.Text = (CStr(Forms!incident2!Title))
.ActiveDocument.Bookmarks("location".Select
.Selection.Text = (CStr(Forms!incident2!Location))
Range = Selection.Range
'** continue the ActiveDocument and Selection statements for each bookmark that you have on the Word Document **
Set objectWord = Nothing
End With
End Function
that is how i create it...i wan to save it so i can send the doc as attachment to email...i manage to send it...but the doc is empty...can anione help pls?thanks...