Start PCAN-Explorer from another application

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
hntranbae
Posts: 1
Joined: Wed 19. Mar 2014, 23:37

Start PCAN-Explorer from another application

Post by hntranbae » Wed 19. Mar 2014, 23:46

I would like to start PCAN-Explorer 5 from another application (i.e. Visual Basic, Visual C#...). What are the dll modules should be included in my application ? The following sample code in the help file does not work

Dim app As Application
Set app = CreateObject("PCANExplorer5.Application")
app.MainWindow.IsVisible = True

Thanks.

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Start PCAN-Explorer from another application

Post by K.Wolf » Thu 20. Mar 2014, 12:20

To start PCAN-Explorer 5 from Visual Basic, you must add the reference to the PCAN-Explorer type library to your project. E.g. in VBA choose Extras->References and set a check mark on "PCAN-Explorer 5 Shared Objects". Then you can use this code to run PCAN-Explorer:

Code: Select all

Dim app As PCANExplorer5.Application
Set app = CreateObject("PCANExplorer5.Application")
app.MainWindow.IsVisible = True
In C# it is similar: Project->Add Reference, and choose "PCAN-Explorer 5 Shared Objects" on the "COM" tab. To run PCAN-Explorer, use this code:

Code: Select all

PCANExplorer5.Application app = new PCANExplorer5.Application();
app.MainWindow.IsVisible = true;

HardyK
Posts: 3
Joined: Sat 13. Sep 2014, 16:42

Start PCAN-Explorer from another application

Post by HardyK » Sat 13. Sep 2014, 16:59

Thanks for the solution.

Even after adding the references, which doesn't seem to be mentioned in the Help File, it still doesn't work in VBA at least. Maybe the reason is because there is a subtle difference between the code snippets in the Help File and the posted solution, but I'm not 100% sure.

Help File Code:

Dim app As Application

Forum Post Code:

Dim app As PCANExplorer5.Application


In summary, I am requesting that Help File article "Automating Tasks from other Applications" is updated as follows:

- Please mention which references to add.
- Please check and/or correct the code for app declaration.

Thanks.

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Start PCAN-Explorer from another application

Post by K.Wolf » Mon 29. Sep 2014, 13:41

OK, we have corrected the example code and mentioned which reference to add.
The updated help file is available with the next release v5.3.5.

Post Reply