TDxInput in Excel VBA

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
Zire18
Posts: 2
Joined: Mon Apr 23, 2012 8:00 am

TDxInput in Excel VBA

Post by Zire18 »

Hello,
iam trying to use the sdk in Excel , but with the following Code i only receive "0". Thank you for your help

Private WithEvents Sensor1 As TDxInput.Sensor
Private WithEvents Keyboard1 As TDxInput.Keyboard
Private WithEvents Device1 As TDxInput.Device

Private Sub CommandButton1_Click()

Set Device1 = New TDxInput.Device
Set Sensor1 = Device1.Sensor
Set Keyboard1 = Device1.Keyboard

Device1.Connect
Dim Translation1 As TDxInput.Vector3D

Set Translation1 = Sensor1.translation

Dim Rotation1 As TDxInput.AngleAxis
Set Rotation1 = Sensor1.rotation

Label1.Caption = Translation1.X

End Sub
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

We have no idea. We have no experience trying to use that interface in VBA with Excel.

The 3DxWare.log file may help to diagnose what is going wrong.

Typically, when we see problems with COM, it is because objects go out of scope and get destroyed when you are not aware of it.
ngomes
Moderator
Moderator
Posts: 3321
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Post by ngomes »

Hi Zire18,

As Jim suggested, try declaring the Sensor1 and Keyboard1 variables in the module scope (outside a funtion or subroutine).
Nuno Gomes
mbonk
Moderator
Moderator
Posts: 181
Joined: Mon Dec 04, 2006 4:06 am

Re: TDxInput in Excel VBA

Post by mbonk »

Zire18 wrote:Hello,
Set Device1 = New TDxInput.Device
End Sub
I would agree with Nuno.

The quoted code creates a new instance of the tdxinput for 3dxware. 3dxware only routes 3D Mouse data to a foreground app with a device instance. Invoking the subroutine creates a new device and querying it for already received data will draw a blank - it is new.

The correct practice would be to create the device once at startup/open and then only query the data in the subroutine.

Markus
XOz3wdWcsePi
Posts: 1
Joined: Wed Feb 04, 2015 2:52 pm

Re: TDxInput in Excel VBA

Post by XOz3wdWcsePi »

Is there an example of coordinates successfully being sent to excel?
Post Reply