Data Type Problem - COM Beginner's question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Data Type Problem - COM Beginner's question

miguel_barcos
Hi,

I need to invoke an MSAccess function that sends a Report Object by
email. I have tested this function manually in access and it works. All
I need to do now is to invoke the COM function from Dolphin to
perform this same task , right? Well, I am frustratingly close, but not
close enough...


I have the following code in a workspace:
----------------------

| AccessApplication IDoCmd |

"create the AccessApplication - this works"
AccessApplication := MSAccess_Application createObject: '{8CC49940-3146-
 11CF-97A1-00AA00424A9F}'.

"open the database - this works"
AccessApplication
      openCurrentDatabase: 'C:\MyDatabase.mdb'
      exclusive: false.

"get the wrapper for the Access.IDoCmd interface - this works"
IDoCmd := AccessApplication doCmd.

"call the send object function - this does not work"
IDoCmd sendObject: 3
objectName:  'MyReport'  asVariant
outputFormat: 'HTML' asVariant
to: '[hidden email]' asVariant
cc: '[hidden email]' asVariant
bcc: '[hidden email]' asVariant
subject: 'This is the subject of the email' asVariant
messageText: ' This is the message text' asVariant
editMessage: 'No' asVariant
templateFile: 'C:\sample.html' asVariant.

----------------------

I get the following exception;

"a HRESULTError('HRESULT Error: An expression you entered is the wrong
data type for one of the arguments.@You tried to run a macro or use a
method to carry out an action, but an expression evaluated to the wrong
data type.
For example, for the Close method you specified a string for the Object
Type argument, but this argument can be set only to certain intrinsic
constants or their numeric equivalents.@@1@@1 (FACILITY_CONTROL)')"

I'm guessing that the exception refers to the first argument
(smallinteger 3). I think I need a 3 because I have determined that in
MSAccess a value of 3 maps to an object type of REPORT.


Below is the invoked method's code:
-----------
SendObject: objectType ObjectName: objectName OutputFormat:
outputFormat To: to Cc: cc Bcc: bcc Subject: subject MessageText:
messageText EditMessage: editMessage TemplateFile: templateFile

"Private - Invoke the SendObject() method of the COM object wrapped by
the receiver.

    HRESULT __stdcall SendObject(
[in, optional, defaultvalue(-1)] AcSendObjectType ObjectType,
[in, optional] VARIANT ObjectName,
[in, optional] VARIANT OutputFormat,
[in, optional] VARIANT To,
[in, optional] VARIANT Cc,
[in, optional] VARIANT Bcc,
[in, optional] VARIANT Subject,
[in, optional] VARIANT MessageText,
[in, optional] VARIANT EditMessage,
[in, optional] VARIANT TemplateFile);
"

<virtual stdcall: hresult 46 sdword variant variant variant
variant variant variant variant variant variant>
^self invalidCall

-----------
I can see from the above comment that it's expecting
an "AcSendObjectType" data type, but it also looks like that it
ultimately gets mapped to an 'sdword' when making the native call. I
thought that a smallinteger could always be coerced to an sdword -
(other examples in the code show exactly that .. )

Am I not interpreting the exception message correctly? Do I need to
create an AcSendObjectType instance? (I don't see such class in the
image)

Any help is greatly appreciated. Thank you.

Miguel Barcos




Sent via Deja.com
http://www.deja.com/


Reply | Threaded
Open this post in threaded view
|

Data Type Problem - COM Beginner's question

miguel_barcos
After wrestling with the code in my original posting, I tried the
following:

----------------------------
| App IDoCmd |

App :=  MSAccess_Application new.
App openCurrentDatabase: 'C:\myTest.mdb' exclusive: false.

IDoCmd := App doCmd.

IDoCmd rename: 'New Report Name' objectType: 3 oldName: 'Old Report
Name'.
----------------------------

To my amazement...This works!  Below is the method that ultimately gets
called:

------------------------
Rename: newName ObjectType: objectType OldName: oldName
        "Private - Invoke the Rename() method of the COM object wrapped
by the receiver.

                HRESULT __stdcall Rename(
                        [in] VARIANT NewName,
                        [in, optional, defaultvalue(-1)] AcObjectType
ObjectType,
                        [in, optional] VARIANT OldName);
        "

        <virtual stdcall: hresult 32 variant sdword variant>
        ^self invalidCall
---------------------

I am puzzled because when I call the sendObject:... method with an
ObjectType of 3 I get a data type exception (see my previous post), but
the above uses an object type of 3 which also gets mapped to an sword
and it works...

I feel this must be something really stupid, but I can get my hands on
it. Any Ideas?

Thanks,
Miguel


Sent via Deja.com
http://www.deja.com/


Reply | Threaded
Open this post in threaded view
|

Re: Data Type Problem - COM Beginner's question

Blair McGlashan
Miguel

You wrote in message news:93n81f$fr3$[hidden email]...
>
> I feel this must be something really stupid, but I can get my hands on
> it. Any Ideas?

See my reply to your other posting, it explains:

http://x59.deja.com/[ST_rn=ap]/threadmsg_ct.xp?thitnum=10&AN=714742618.1&mhi
tnum=2&CONTEXT=979320118.1372848172

Regards

Blair