ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Module problem (https://www.excelbanter.com/excel-programming/328353-module-problem.html)

Pat

Module problem
 

What change do I need to make so that the code will carry out the following
instruction

Me.CloseExcelExport.Enabled = False

it does not seem to like "Me" method.

Thanks if you can be of help.
Pat



Rob Bovey

Module problem
 
"Pat" wrote in message
...
What change do I need to make so that the code will carry out the
following instruction

Me.CloseExcelExport.Enabled = False

it does not seem to like "Me" method.


Hi Pat,

I'm not sure exactly what the CloseExcelExport property is, but the Me
keyword can only be used inside a class module. Class modules include not
only the modules that you can add manually through the VBE, but also the
code behind modules for UserForms, Worksheets and ThisWorkbook.

Although it's probably obvious, the Me keyword can only be used to
access properties and methods of the class in which it is used. If you need
to call a property or method located in another class you'll need to use an
object reference to that class.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm



Bob Phillips[_7_]

Module problem
 
Pat, I guess this is a 2003 method, and as I don't have 2003 I don't see
it.

You can go to the object browser in the VBE and type that in the search ox,
and see which object it applies to.

--
HTH

Bob Phillips

"Pat" wrote in message
...

What change do I need to make so that the code will carry out the

following
instruction

Me.CloseExcelExport.Enabled = False

it does not seem to like "Me" method.

Thanks if you can be of help.
Pat





Pat

Module problem
 
Hi gentlemen,
Thank you for helping out. It seems I need to clarify what precisely I wish
to do. On one sheet (say, sheet1) a custom commandbutton is clicked to bring
the user to another sheet (say, sheet2). in sheet2 another custom
commandbutton (called, CloseExcelExport) is clicked which runs code. Once
the code has completed the instructions it then ghosts out the button, hence
the instruction,

Me.CloseExcelExport.Enabled = False

What I want to do is incorporate the code in CloseExcelExport with the
commandbutton in sheet1, but still retain the commandbutton in sheet2.

Pat





"Bob Phillips" wrote in message
...
Pat, I guess this is a 2003 method, and as I don't have 2003 I don't see
it.

You can go to the object browser in the VBE and type that in the search

ox,
and see which object it applies to.

--
HTH

Bob Phillips

"Pat" wrote in message
...

What change do I need to make so that the code will carry out the

following
instruction

Me.CloseExcelExport.Enabled = False

it does not seem to like "Me" method.

Thanks if you can be of help.
Pat







Rob Bovey

Module problem
 
"Pat" wrote in message
.. .
Thank you for helping out. It seems I need to clarify what precisely I
wish
to do. On one sheet (say, sheet1) a custom commandbutton is clicked to
bring
the user to another sheet (say, sheet2). in sheet2 another custom
commandbutton (called, CloseExcelExport) is clicked which runs code. Once
the code has completed the instructions it then ghosts out the button,
hence
the instruction,

Me.CloseExcelExport.Enabled = False

What I want to do is incorporate the code in CloseExcelExport with the
commandbutton in sheet1, but still retain the commandbutton in sheet2.


Hi Pat,

If you want to address a command button called CloseExcelExport, which
is located on Sheet2, from code located in Sheet1 you would do it like so
(assuming the CodeName of the target worksheet is in fact Sheet2):

Sheet2.CloseExcelExport.Enabled = False

If you want this button and a button on Sheet1 to call the same code,
there are several ways to do it. The easiest would be to create a new method
(Public Sub) in Sheet2 and call it from both places. If you have the
following in Sheet2:

Public Sub MyMethod()
''' Your code here
End Sub

You can call it from Sheet1 like so:

Sheet2.MyMethod

And it can be called from within Sheet2 like any other subroutine.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm




All times are GMT +1. The time now is 10:09 PM.

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