KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: VBA Direct API Calls
Topic Summary: Can Advanced Scripting bypass the user interface?
Created On: 07/28/2022 07:45 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 VBA Direct API Calls   - IceRafter - 07/28/2022 07:45 PM  
 VBA Direct API Calls   - Alan Cantor - 07/28/2022 10:23 PM  
 VBA Direct API Calls   - R. Wilke - 07/29/2022 09:42 PM  
 VBA Direct API Calls   - IceRafter - 07/30/2022 04:50 AM  
 VBA Direct API Calls   - R. Wilke - 07/30/2022 06:36 AM  
Keyword
 07/28/2022 07:45 PM
User is offline View Users Profile Print this message

Author Icon
IceRafter
Junior Member

Posts: 21
Joined: 01/11/2019

Have been working on a library of SolidWorks voice-macros for the past six months or more that perform CAD automation using the traditional user interface of menu pull-downs and keyboard shortcuts.

More recently have spent some time studying the SolidWorks API, and it occurred to me that I could eliminate quite a bit of design-intent ambiguity and save significant double-programming/documentation effort if only I could make SolidWorks API calls directly from Dragon Advanced Scripting.

Has anyone done anything similar with say Excel, or Word? There are no doubt security considerations, but I can't think of a good reason why this wouldn't be feasible?


Screenshot of partial SolidWorks API listing…




-------------------------
Ice Rafter

 07/28/2022 10:23 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4405
Joined: 12/08/2007

Yes. It's most straightforward with Word, less so for Excel, Outlook, etc.

You can copy Word macros from the VBA editor and paste them directly into Dragon's Advanced Scripting window. Then click anywhere in the script, press Alt + Enter, and set the reference to "Microsoft Word XX.00 Object Library (X.X)"

(The values of X will depend on the version of Word.)

This code toggles subscript on and off programmatically, without involving the user interface.

Sub Main
Selection.Font.Subscript = wdToggle
End Sub

There are a handful of VBA Word macros that won't work as Dragon commands, but they're rare.
 07/29/2022 09:42 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7921
Joined: 03/04/2007

You need to reference the DLL which holds the API, as indicated by Alan, create and instantiate an object, use it given the syntax in the documentation, and dispose of it when you're done.

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



No need to buy if all you want to do is try ...

DragonCapture KB Download (Latest)
DragonCapture Homepage

 07/30/2022 04:50 AM
User is offline View Users Profile Print this message

Author Icon
IceRafter
Junior Member

Posts: 21
Joined: 01/11/2019

Thanks for the help guys, it almost works except there seems to be an incompatibility issue between VBA versions that I'm not sure is worth trying to fix.

Included all the SolidWorks modules as suggested, but this is the resulting Dragon error dialogbox -- ActiveX and Windows Sockets are expected by Dragon, but deprecated, correct? So this can NEVER get resolved by fiddling with the SolidWorks side, agreed?

Does anyone know if Microsoft might update the VBA engine in Dragon someday? They DID complete the Dragon acquisition from Nuance, yes?

Oh well, back to firing SolidWorks macros via the user interface!



-------------------------
Ice Rafter

 07/30/2022 06:36 AM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7921
Joined: 03/04/2007

If I were you, I wouldn't give up so soon. This is just a very wild guess, but you might need another external reference, or another version of the WINSOCK.DLL, which depends on what SolidWorks requires. Most likely, this is not a Dragon thing.

I would go on looking at what Google comes up with if you enter the error messages, and looking at the SolidWorks documentation. I admit that don't have the faintest idea about SolidWorks.

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



No need to buy if all you want to do is try ...

DragonCapture KB Download (Latest)
DragonCapture Homepage

KnowBrainer Speech Recognition » Commands, Scripts, and Macros - Dragon » VBA Direct API Calls

Statistics
32390 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 1 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 355 guests browsing this forum, which makes a total of 356 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2022 FuseTalk™ Inc. All rights reserved.