Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


OLE and Passing Parameters

Keywords:   1257 Type Mismatched error named parameters

Question:

I am trying to open a new datasource in word via OLE. Here is the example in VBA that I can't get to work in Winbatch.
Set myDoc = Documents.Add
With myDoc.MailMerge
    .MainDocumentType = wdFormLetters
    .OpenDataSource _
        Name:="C:\MSOffice\Access\Samples\Northwind.mdb", _
        LinkToSource:=True, AddToRecentFiles:=False, _
        Connection:="TABLE Orders
End With

how do you format multiple parameters in the winbatch statement.

Here is what I have that doesn't work.

testdoc = "c:\mailmerge.doc"
wdOpenFormatAuto = 0
MMrgDSNCS = "QUERY Check List"
MMrgDSNQS = "SELECT * FROM [Check List]"
App = ObjectOpen("Word.Application")
Docs = App.Documents
Doc = Docs.Open(testdoc)
MMrgObj = Doc.MailMerge
MMrgObj.OpenDataSource(newDSN, LinkToSource=1, Format = wdOpenFormatAuto, Connection = MMrgDSNCS, SQLStatement = MMrgDSNQS)
I tried this and I get a 1257 Type Mismatched error:
MMrgObj.OpenDataSource(newDSN,"LinkToSource:=True","Connection:=%MMrgDSNCS%","SQLStatement:=%MMrgDSNQS%")
Thanks for your help!!!!

Answer:

My guess is that you are dealing with named parameters...
MMrgObj.OpenDataSource(newDSN:: LinkToSource=1, Format = wdOpenFormatAuto, Connection = MMrgDSNCS, SQLStatement = MMrgDSNQS)

Question:

Hi. I'm getting an this error while trying to set a value to a field in a Lotus Notes document.
My error is OLE Error 1257: OLE: Type Mismatch.
My code to this point looks like this:
session = objectopen("Notes.NotesSession")
db = session.getdatabase("", "names.nsf")
doc = db.CreateDocument
doc.sendto("steve buechler")
I get this error on line 4. All I'm attempting to do is set the value of the item SendTo on a Lotus Notes document. Any ideas what I'm doing wrong?

Answer:

Is sendto a method or a property? my guess is it is a property. It sounds like maybe it's actually supposed to be a property assignment, but the equals sign is missing: e.g., doc.sendto = "steve buechler"

Try this instead....

session = objectopen("Notes.NotesSession")
db = session.getdatabase("", "names.nsf")
doc = db.CreateDocument
doc.sendto ="steve buechler"

Article ID:   W14674
Filename:   OLE and Passing Parameters.txt