View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Do not understand

here is one example for the Sub Compress. Replace runwiththisname.xls with
your worksheet name. When Ctrl Q is press will only work when the workbook
is named runwiththisname.xls

Sub Compress()

'

' Compress Macro

' Macro recorded 2007-02-22 by Gunnel Bengtsson

'

' Keyboard Shortcut: Ctrl+q

'
if (strcomp(MyworkbookName, "runwiththisname.xls") = 0) then
ActiveSheet.Rows.RowHeight = 13
end if

End Sub

"Prixton" wrote:

Hi Joel,

I am sorry but I still do not understand.

Here is my macro and let us say that my workbook is called Smith.exe, should
the toolbar be called Smith as well?



Here is my macro:

Sub Compress()

'

' Compress Macro

' Macro recorded 2007-02-22 by Gunnel Bengtsson

'

' Keyboard Shortcut: Ctrl+q

'

ActiveSheet.Rows.RowHeight = 13



End Sub

Sub Expand()

'

' Expand Macro

' Macro recorded 2007-02-22 by Prixton

'

' Keyboard Shortcut: Ctrl+e

'

ActiveSheet.Rows.AutoFit



End Sub



How should I complete it?



Thanks again for your help even if I am slow and do not understand



"Joel" skrev i meddelandet
...
Yuou have to look at macros in the tools - Macros - visual Basic editor.

You said you wanted tthe macro which work with the tool bar only to run
when
the workbook has a certain name. The tool bars are inside the
spreadsheet.

It is like the Workbook is the Family Jones.
Each worksheet (tab) has a name Alice, Bob, Nancy
The Toolbars also have name Thom.

If you name the Workbook Smith you will still have worksheets Alice, Bob,
Nancy, but you won't have toolbar Thom.

bob Jones

"Prixton" wrote:

Hi Joel,
Thanks for your answer. However I do not understand it.
If my workbook is called aaa.xls and my toolbar is called MyToolbar, how
should the commands be in the macro?

Thanks again

"Joel" skrev i meddelandet
...
If you add MyworkbookName = ThisWorkbook.name to the beginning of the
macro.

then add an if statement at the begfinning of the macro

if (strcomp(MyworkbookName, "runwiththisname.xls") = 0) then


end if



"Prixton" wrote:

Hi,
I have some macros that shall only run in a specific workbook. I have
made a
toolobar form those macros but I can not make the toolbar appear only
when
opening that special workbook. I also want the toolbar to disappear
when
closing the workbook.

Thanks for all help