Skip to main content
12-Amethyst
November 29, 2022
Solved

Prime 8: Cant use API with Excel

  • November 29, 2022
  • 3 replies
  • 2931 views

Hi,

 

I was doing some calculations using Prime 7 and Excel through macros. Basically, the program passes some values from Excel to Mathcad to calculate and the results are printed back to Excel. It worked fine.

 

I recently formatted my laptop and installed Prime 8. I am waiting for the license so, in the meantime, I am using the 30-days trial with full functionality.

 

I tried to use the same Prime-Excel program but it shows the following error when I run the macro: "User-defined type not defined". I have the Ptc.MathcadPrime.Automation.tlb file to VBA, as shown in the attached image.

 

Is there something I am missing? Maybe this functionality is restricted to users with license?

 

Thanks!

Best answer by DM_10127316

Hi everyone,

 

The problem has been solved. The code I had used the previous Mathcad 15 API commands. It worked fine before because I had Mathcad 15 and Prime 7 installed. So, after I formatted my laptop and installed Prime 8, I got the error.

 

I deleted:

Dim MC As Mathcad.Application
Dim WK As Mathcad.Worksheets
Dim WS As Mathcad.Worksheet

 

and left:

Dim MC As Ptc_MathcadPrime_Automation.Application
Dim WS As Ptc_MathcadPrime_Automation.Worksheet
Dim WStest As Ptc_MathcadPrime_Automation.Worksheet

 

and my script works fine now.

 

Thanks!

 

3 replies

24-Ruby III
November 30, 2022
12-Amethyst
November 30, 2022

Thanks! Unfortunately, that solution doesnt seem to help with my problem.

 

My issue is that VBA doesnt recognise the user-defined "Mathcad.application" type, which is part of Mathcad API.

 

 

24-Ruby III
November 30, 2022

@DM_10127316 wrote:

Hi,

 

I was doing some calculations using Prime 7 and Excel through macros. Basically, the program passes some values from Excel to Mathcad to calculate and the results are printed back to Excel. It worked fine.

 

I recently formatted my laptop and installed Prime 8. I am waiting for the license so, in the meantime, I am using the 30-days trial with full functionality.

 

I tried to use the same Prime-Excel program but it shows the following error when I run the macro: "User-defined type not defined". I have the Ptc.MathcadPrime.Automation.tlb file to VBA, as shown in the attached image.

 

Is there something I am missing? Maybe this functionality is restricted to users with license?

 

Thanks!


Hi,

I think the best way how to get the  answer is send your question to PTC Support. Please open Case on PTC Support web page.

12-Amethyst
November 30, 2022

Thanks! I will wait for the license, see if the problem persist, and then submit my issue. 

 

But, if anyone had the same issue, please let me know!

24-Ruby III
December 1, 2022
DM_1012731612-AmethystAuthorAnswer
12-Amethyst
December 7, 2022

Hi everyone,

 

The problem has been solved. The code I had used the previous Mathcad 15 API commands. It worked fine before because I had Mathcad 15 and Prime 7 installed. So, after I formatted my laptop and installed Prime 8, I got the error.

 

I deleted:

Dim MC As Mathcad.Application
Dim WK As Mathcad.Worksheets
Dim WS As Mathcad.Worksheet

 

and left:

Dim MC As Ptc_MathcadPrime_Automation.Application
Dim WS As Ptc_MathcadPrime_Automation.Worksheet
Dim WStest As Ptc_MathcadPrime_Automation.Worksheet

 

and my script works fine now.

 

Thanks!