T
Tammy
Okay, I have several questions. One, I am trying to take
info from Access to a Word document & insert it at a
bookmark - and at a later time, use the text at that
bookmark. However, the following errors occur.
I am having problems calling this particular procedure
which, depending on when it is called, will have a
different number of arguments. I am having problems with
passing only a couple - even though they are
stated "optional". And I am getting the error "type
mismatch" on the line "BMRange.Text = strText" any
suggestions?
Here is the code:
Call SOPWork.OpenWord(strName,,dtDate,strRev,)
'***#arguments getting "expression" error**
Function OpenWord(strDocName As String, Optional Author
As String, Optional dtDate As Date, Optional Revision As
String, Optional Path As String, Optional Temp As String)
On Error GoTo Err_Edit:
Dim oApp As Object
Dim oDoc As Object
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.Documents.Add(Path & Temp)
Call setBM(oDoc, "DocName", strDocName)
Call setBM(oDoc, "Author", Author)
Call setBM(oDoc, "Date", dtDate)
Call setBM(oDoc, "Revision", Revision)
***type mismatch on return?? or at 'BMRange =' line****
oApp.Selection.Goto wdGoToBookmark, Name:="StartHere"
oApp.Visible = True
GoTo exit1:
Err_Edit:
MsgBox Err.Description
MsgBox Err.source
Resume exit1:
exit1:
End Function
Sub setBM(objDoc As Object, strBookMark As String,
strText As Variant)
Set objDoc = ActiveDocument
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(strBookMark).Range
BMRange.Text = strText **type mismatch error***
ActiveDocument.Bookmarks.Add strBookMark, BMRange
End Sub
info from Access to a Word document & insert it at a
bookmark - and at a later time, use the text at that
bookmark. However, the following errors occur.
I am having problems calling this particular procedure
which, depending on when it is called, will have a
different number of arguments. I am having problems with
passing only a couple - even though they are
stated "optional". And I am getting the error "type
mismatch" on the line "BMRange.Text = strText" any
suggestions?
Here is the code:
Call SOPWork.OpenWord(strName,,dtDate,strRev,)
'***#arguments getting "expression" error**
Function OpenWord(strDocName As String, Optional Author
As String, Optional dtDate As Date, Optional Revision As
String, Optional Path As String, Optional Temp As String)
On Error GoTo Err_Edit:
Dim oApp As Object
Dim oDoc As Object
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.Documents.Add(Path & Temp)
Call setBM(oDoc, "DocName", strDocName)
Call setBM(oDoc, "Author", Author)
Call setBM(oDoc, "Date", dtDate)
Call setBM(oDoc, "Revision", Revision)
***type mismatch on return?? or at 'BMRange =' line****
oApp.Selection.Goto wdGoToBookmark, Name:="StartHere"
oApp.Visible = True
GoTo exit1:
Err_Edit:
MsgBox Err.Description
MsgBox Err.source
Resume exit1:
exit1:
End Function
Sub setBM(objDoc As Object, strBookMark As String,
strText As Variant)
Set objDoc = ActiveDocument
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(strBookMark).Range
BMRange.Text = strText **type mismatch error***
ActiveDocument.Bookmarks.Add strBookMark, BMRange
End Sub