VB Project

  • Thread starter Thread starter Aless
  • Start date Start date
A

Aless

In an Excel workbook there is some VB coding with various routines. How can
i assign a routine to a toolbar button (I assume this will have to be a
macro button) which will trigger the routine. There are no macros in this
workbook when you press Alt+F8.

Would appreciate your help.

dg
 
The code is in ThisWorkbook module and one of the procedures is PrintAndSave
which I want to be able to run from the work sheet but I don't know how to.

Thank you for your help.

Dinesh Gudka
 
Hi Bob

It does not look as if the procedure has any arguments. This is the code:

Private Sub SaveAndPrintInvoice()
ActiveWorkbook.ActiveSheet.PrintOut
End Sub

There are other procedures within the module most of which are without
arguments as well, but none of them show up under list of macros!

Does this make sense?

Dinesh
 
Aless,

The list will not include macros contained behind the worksheet or macros
that are declared as "Private".
You macros must be in a standard module and be public.

Otherwise -
View > Toolbars > Customize
select the Commands tab and goto Macros
select one of the two choices and drag it to the tool bar.
right click the new button and click Assign Macro
select a macro from the list and click OK.

steve
 
Dinesh,

These could well be declared as Private procedures, or may even be
Functions. Private are only applicable to the module they are in, so they
don't show, and Functions return a result, so they don't show either.

Does this cover them?
 
Hi Bob

You are right, all the procedures are declared as Private Sub .....

I'll remove Private from one of the procedures and see if I can trigger it
via macros.

Thank you for taking the time and trouble to help me, much appreciated.

Dinesh
 
Back
Top