BrianFawcett
Registered User.
- Local time
- Today, 00:57
- Joined
- May 3, 2010
- Messages
- 63
I am writing scripts for a database I maitain. I have Word documents which I want to open a populate with two fields form the Access form if the user chooses certain products.
When I am testing the code I am getting an error: "Run Time Error 13. Type Mismatch." This occurs on the code below in bold. Can anyone tell me why?
Dim oApp1 As Object
'Set Word as an application and make it invisible
Set oApp1 = CreateObject("Word.Application")
oApp1.Visible = True
'Path and name of the word document for this product
oApp1.Documents.Add ("I:\DeptShare\C\Customer Service\Confidential\Custcare\2 - Reporting\New DDC Order Tracker\Order Tracker Documents\POP UP DS MACHINES.docx")
'this is the bookmark for the In House Reference number
oApp1.ActiveDocument.Bookmarks("InHouseRef").Select
'this is the field in the Access form that contains the data for the bookmark
oApp1.Selection.Text = Forms![New Entry Form]![InHouseRef]
'This is the bookmark for the Customer Name
oApp1.ActiveDocument.Bookmarks("Name").Select
'This is the field in the Access form that contains the data for the bookmark
oApp1.Selection.Text = Forms![New Entry Form]![DealerName]
'View the Word document
'oApp1.Visible.true
Exit Sub ' Perform some action.
When I am testing the code I am getting an error: "Run Time Error 13. Type Mismatch." This occurs on the code below in bold. Can anyone tell me why?
Dim oApp1 As Object
'Set Word as an application and make it invisible
Set oApp1 = CreateObject("Word.Application")
oApp1.Visible = True
'Path and name of the word document for this product
oApp1.Documents.Add ("I:\DeptShare\C\Customer Service\Confidential\Custcare\2 - Reporting\New DDC Order Tracker\Order Tracker Documents\POP UP DS MACHINES.docx")
'this is the bookmark for the In House Reference number
oApp1.ActiveDocument.Bookmarks("InHouseRef").Select
'this is the field in the Access form that contains the data for the bookmark
oApp1.Selection.Text = Forms![New Entry Form]![InHouseRef]
'This is the bookmark for the Customer Name
oApp1.ActiveDocument.Bookmarks("Name").Select
'This is the field in the Access form that contains the data for the bookmark
oApp1.Selection.Text = Forms![New Entry Form]![DealerName]
'View the Word document
'oApp1.Visible.true
Exit Sub ' Perform some action.