Type Mismatch Error

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.
 
You need to step through the code using a break point and then pressing F8 to find the line that errors. Failing that, try opening the code module and select Debug and Compile, which may show the problem line. Post that line here.

One thing I have noticed in your post, and it may just be a copy and paste error, is that your have

Code:
oApp1.ActiveDocument.Bookmarks("InHouseRef").Selec t

This clearly wont help when it is supposed to be 'Select
 
One thing I have noticed in your post, and it may just be a copy and paste error, is that your have

Code:
oApp1.ActiveDocument.Bookmarks("InHouseRef").Selec t

This clearly wont help when it is supposed to be 'Select

Ted:
That is just a quirk of the vBulletin database software and it won't happen if code tags are used, but it will happen on certain sentences if they are not.
 
Ted, The line of code that is erroring is this one below:

oApp1.Selection.Text = Forms![New Entry Form]![DealerName]
 

Users who are viewing this thread

Back
Top Bottom