ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Project (https://www.excelbanter.com/excel-programming/271594-vbulletin-project.html)

Aless

VB Project
 
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



Aless

VB Project
 
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

"Bob Phillips" wrote in message
...
Not clear what you are saying here. If there are no macros, where is the

VB
code that you refer to?

And why do you want to put it to a toolbar button? I assume that the code
may be event code, and sitting in a sheet code module or the ThisWorkbook
module.

Tell us where it is and what you want to do with it.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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







Aless

VB Project
 
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


"Bob Phillips" wrote in message
...
Dinesh,

Just because it's in ThisWorkbook you should still see it from the macro
list. If you can't that probably means that it has arguments. In this

case,
you could create another procedure, in a normal module, to call it with

the
argument value, e.g.

ThisWorkbook.PrintAndSave argValue

and then assign this to a toolbar button. If you want it to be dynamic,

then
you will need to get the argValue via an input box, or the current
selection, or whatever.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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

"Bob Phillips" wrote in message
...
Not clear what you are saying here. If there are no macros, where is

the
VB
code that you refer to?

And why do you want to put it to a toolbar button? I assume that the

code
may be event code, and sitting in a sheet code module or the

ThisWorkbook
module.

Tell us where it is and what you want to do with it.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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











steve

VB Project
 
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

"Aless" wrote in message
...
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





Bob Phillips[_5_]

VB Project
 
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?

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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


"Bob Phillips" wrote in message
...
Dinesh,

Just because it's in ThisWorkbook you should still see it from the macro
list. If you can't that probably means that it has arguments. In this

case,
you could create another procedure, in a normal module, to call it with

the
argument value, e.g.

ThisWorkbook.PrintAndSave argValue

and then assign this to a toolbar button. If you want it to be dynamic,

then
you will need to get the argValue via an input box, or the current
selection, or whatever.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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

"Bob Phillips" wrote in message
...
Not clear what you are saying here. If there are no macros, where is

the
VB
code that you refer to?

And why do you want to put it to a toolbar button? I assume that the

code
may be event code, and sitting in a sheet code module or the

ThisWorkbook
module.

Tell us where it is and what you want to do with it.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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













Aless

VB Project
 
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

"Bob Phillips" wrote in message
...
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?

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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


"Bob Phillips" wrote in message
...
Dinesh,

Just because it's in ThisWorkbook you should still see it from the

macro
list. If you can't that probably means that it has arguments. In this

case,
you could create another procedure, in a normal module, to call it

with
the
argument value, e.g.

ThisWorkbook.PrintAndSave argValue

and then assign this to a toolbar button. If you want it to be

dynamic,
then
you will need to get the argValue via an input box, or the current
selection, or whatever.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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

"Bob Phillips" wrote in message
...
Not clear what you are saying here. If there are no macros, where

is
the
VB
code that you refer to?

And why do you want to put it to a toolbar button? I assume that

the
code
may be event code, and sitting in a sheet code module or the
ThisWorkbook
module.

Tell us where it is and what you want to do with it.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Aless" wrote in message
...
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
















All times are GMT +1. The time now is 01:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com