Cancel
Showing results for 
Search instead for 
Did you mean: 

Using VBA for writing an Excel File. Not all VBA commands are working.

Creator
Creator

Hi community,

 

i have a model in which i have a various number of tables. I have created an activex interface for writing my tables into one excel file. Each table is saved as a new worksheets. So far its working great. But I saw that there are some VBA commands which are helpful for my task but are not working in my code. For instance, there is the command of moving worksheets within my excel file.

 

activex.application.Worksheets("Sheet1").Move after:=Worksheets("Sheet3"

 

I´ll get an error if I using this line above in my code. But I dont know why. Is it because VBA is in Plant Simulation limited to the commands which are in the activex.Typinformationen?

 

Thanks in advance 

 

Lars

2 REPLIES

Re: Using VBA for writing an Excel File. Not all VBA commands are working.

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
if you have set excel.application as class name in the ActiveX interface and activeX is the name of the interface, then activeX is excel itself, you need also to adress the workbook

activex.ActiveWorkbook.Worksheets("Sheet1").Move after:=activex.ActiveWorkbook.Worksheets("Sheet3")
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Using VBA for writing an Excel File. Not all VBA commands are working.

Creator
Creator

Many thanks.