Jump to content



Featured Articles

Check out the latest featured articles.

File Library

Check out the latest downloads available in the File Library.

New Article

Product Viscosity vs. Shear

Featured File

Vertical Tank Selection

New Blog Entry

Low Flow in Pipes- posted in Ankur's blog

0

Excel Visual Basic Help


19 replies to this topic
Share this topic:
| More

#1 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 24 August 2020 - 11:11 AM

Hi,

I hv integrated my simulation model in Aspen Plus with Excel using aspen Simulation Workbook here.

I want your help how we can operate the button using Excel VB command button ??

Regards,
Chetan Chavan
M 9503879078

#2 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 25 August 2020 - 05:28 AM

Dear Sir,

I want help from our members to solve this issue of excel macros and command button . I have already one command button on my excel sheet and I want to operate another enable button on my excel sheet here ?

Regards,
Chetan Chavan

#3 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 25 August 2020 - 05:43 AM

How to write visual basic macro to operate the other button!!

#4 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 25 August 2020 - 09:28 AM

Demands are seldom successful. But you might get response if you show some work. Or do some research first.

 

Bobby



#5 MrShorty

MrShorty

    Gold Member

  • ChE Plus Subscriber
  • 517 posts

Posted 25 August 2020 - 10:29 AM

Here are MSFT's instructions for how to assign a macro to a button -- if that is the main thrust of your question: https://support.micr...ad-9c72c843a283



#6 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 25 August 2020 - 10:30 AM

Dear Sir,

I have a Enable button on excel Ribbon Tab here. This enable button is used to start Aspen Simulation Workbook here.now I have another custom made button on excel sheet itself. I can click this button on and off here. I want to operate this Enable Button with This custom made button here.i hv written custom code in VBA excel bit it is not working as I m not able to find which pareter to be written for Enable button ??

#7 PaoloPemi

PaoloPemi

    Gold Member

  • Members
  • 549 posts

Posted 25 August 2020 - 02:15 PM

I have not Aspen to test, however with Prode Properties and VBA I utilize the solution proposed by MrShorty and it works fine, see also  the Excel pages provided with the software, when you click on the button the VBA code inside the sub is executed.

With Aspen maybe you need to add some settings, have you found working examples in Aspen web site ?



#8 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 25 August 2020 - 11:21 PM

Dear Sir,

I know how to create command button in excel here. I have already have a button here. But I want to operate another Button called "Enable " existing on Ribbon Bar here.

How to write a code for that ???

Regards,
Chetan Chavan

#9 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 25 August 2020 - 11:27 PM

Let us say I have two buttons already created , one is in Excel Ribbon and other is in Excel Sheet itself.now I want to operate first button with second button how to do it now ?

Regards

#10 PaoloPemi

PaoloPemi

    Gold Member

  • Members
  • 549 posts

Posted 26 August 2020 - 01:11 AM

to add a button on quick access bar see

https://support.micr...ba-927f84eb5d2c

I have tested this solution with Prode Properties, see the small button with label Phase Envelope,  when you click on that button Prode calculates the phase envelope as shown,

Attached File  phaseenvelope.jpg   107.6KB   0 downloads

you should be able to create a equivalent solution with Aspen

 

 



#11 MrShorty

MrShorty

    Gold Member

  • ChE Plus Subscriber
  • 517 posts

Posted 26 August 2020 - 09:58 AM

But I want to operate another Button called "Enable " existing on Ribbon Bar here.
Are you wanting to manipulate the button itself from within VBA, or are you wanting to call the macro associated with "Enable" button?

 

If the former -- you want VBA to manipulate properties of the "Enable" button -- buttons are members of the Shapes collection. You access the button through the shapes collection, then manipulate its properties as you would with properties of other objects. The easiest way to see how this works might be to record a macro of you manually manipulating the button and see how the macro recorder records those actions. https://docs.microso...pi/excel.shapes

 

If the latter -- you want to call the macro associated with the "Enable" button from another VBA procedure -- you can use the Call statement (noting that the Call keyword is often omitted). https://docs.microso.../call-statement

 

Are either of those what you are wanting to do?



#12 frpe

frpe

    Veteran Member

  • Members
  • 47 posts

Posted 26 August 2020 - 11:23 AM

as far as I know, the simulation workbook ribbon in Excel includes many buttons, you create a dynamic link to transfer data between Aspen and Excel, then you click on the different buttons to export tags, values etc.

What is the purpose of your application ?  Do you wish to customize those buttons ?



#13 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 27 August 2020 - 10:48 PM

There is a button on my aspen Simulation enabled excel sheet called Enable in Excel Ribbon. I want to operate this button from other button on excel sheet . How to write the code can someone help me with sample code

#14 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 27 August 2020 - 10:49 PM

When u connect simulation workbook to Aspen Model, you need to click two buttons one is called Enable and second is called Connect to Model .Therse are on Excel Ribbon .I want to operate this Enable button now

#15 frpe

frpe

    Veteran Member

  • Members
  • 47 posts

Posted 28 August 2020 - 06:18 AM

The simulation workbook doesn't require coding, to establish / manage a connection between Excel and Aspen the ribbon includes several buttons : Enable/Disable , Refresh etc.
Once the connection is active there are other buttons to transfer tags, values etc.
It seems you wish to customize the behavior of these buttons, for that maybe you need access to some source or knowledge about the methods to call in order to enable / disable the link.
Another possibility is to adopt VBA as suggested by MrShorty and PaoloPemi, you can create a sub / macro and assign the macro to the button.
Then, with an external application as Aspen you can put some code to activate a dynamic link or exchange data.
Or, with an add-in library as Prode, you have direct access to the methods as for Excel libraries.



#16 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 30 August 2020 - 12:27 AM

Dear frpe Sir,

You are exactly right. I want to operate this ENable button from other command button on excel now.

I also want sample VBA code to do this .

I am able to operate other ribbon buttons as Connect and Activate with command buttons in excel as these are Aspen Macros and we just need to connect it to macros .

But there is no ready made aspen macro to operate Enable button . So I want sample code in VBA to do this .

Request your help here .

Thanks

Best Regards,
Chetan Chavan

#17 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 30 August 2020 - 06:05 AM

Request members to comment on this and help me

#18 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 30 August 2020 - 06:51 PM

You seem to need help for many things. You should show a little initiative. For VBA, get a book to find your answers. VBA for Excel by John Walkenbach is a good one. We're not going to do your job for you.

 

Bobby



#19 CHEMSTRONG

CHEMSTRONG

    Gold Member

  • Members
  • 348 posts

Posted 03 September 2020 - 12:16 PM

Dear Sir,

How to locate that Enable button in VBA code ?

I hv written some code but failed to understand how to link to that parameter of button enable ??

#20 MrShorty

MrShorty

    Gold Member

  • ChE Plus Subscriber
  • 517 posts

Posted 03 September 2020 - 02:11 PM

It still is not clear to me if you are trying to change something about the enable button or merely call the same procedure that the enable button calls.

 

A quick internet search finds a few sites that claim that you cannot change/edit/add/manipulate ribbon elements from VBA. Most talk about using an editor that can create/edit/manipulate the ribbon xml code. If you are trying to change a button that is on a custom ribbon, it is probably easiest to find and download one of these ribbon editors. Ron de Bruin has been around the Excel community for a long time and seems to know his stuff. Here's his page about making changes to ribbons: http://www.rondebrui...in/section2.htm

 

If you are trying to call the same procedure that is called by this enable button, then you should not even need to access the button. As I suggested earlier, you can simply use the Call statement.






Similar Topics