cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Read in Excel sheet tags via visual basic

Raiko
17-Peridot

Read in Excel sheet tags via visual basic

Hi all,

is it possible to read in the tags of the sheets in an excel work sheet? I'd like to populate a list box with the tags so that I can choose by clicking which sheet I wish to read in.

Has anybody some VB code that might be useful?

Thanks in advance

Raiko

ACCEPTED SOLUTION

Accepted Solutions

Which script are you getting the error with? Push button or list box?

Mike

View solution in original post

12 REPLIES 12

Do you mean the name of the worksheet within Excel?

Mike

Hello Mike

yes. The several sheets within one Excel file (i.e. tabs) are labelled sheet 1 to... Quite often I get Excel files with measurement data where these names have been altered (e.g. temp. reading 11...) so that I need to open the excel file in order to get the tab names. Any automation process on this task would help.

Cheers

Raiko

Knew that you'd answer first 😉

This sort of works, have a look.

I cannot find the code to do it fully automated, but this is a work around. I have used the function below within the excel worksheet to extract the tab name, and then called into Mathcad. It would mean whoever creates the Excel file doing a little extra work.

Have a look at both of the attached and let me know what you think.

Mike

Hi Mike,

thank's for the effort. I have a problem however with ActiveX. This is the error message I get when invoking your script

What's wrong?

Raiko

Forget the first proposal. I have sorted it. Save both files to your desktop.

Clipboard01.jpg

Mike

Mike,

that works. Let's see whether I get the guys down in the basement to write down the tags on the first page.

Thanks again

Raiko

that works. Let's see whether I get the guys down in the basement to write down the tags on the first page.

Thanks again

No problem.

They shouldn’t have to do anything extra. The second example is fully automated. All you need to do is select the Excel workbook and the scripted components should do the rest.

Mike

Mike,

I have encountered an error when opening the file (both files are saved to the desktop). Mathcad 15 M010.

VB_Error.jpg

P.S. Can be it is necessary to use in a script a relative path for file Excel?

Which script are you getting the error with? Push button or list box?

Mike

Hello Mike,

I have this anoying problem I can't solve. Your code worked fine, but when I copied it into another drop list (in order to choose the tabs from that list) it refused to work.

Can you have a look at the attached MC 15 sheet and check what's wrong?

Thanks in advance

Raiko

Sorry for the late reply. I am currently traveling across Europe and don't have Internet access, except in the Hotel.

I'll have a look later for you.

Mike

Hello Mike,

no sweat. Take your time.

Here is a more advanced version. The previous one is faulty.

Thanks

Raiko

Announcements

Top Tags