|
-
Mar 21st, 2000, 12:39 AM
#1
Thread Starter
Member
Does it has in VBA for Excel the same function "AutoExec" and "AutoOpen" like these in VBA for Word?
Thanks
Scand
-
Mar 21st, 2000, 01:59 AM
#2
Frenzied Member
Worksheet, in Excel, has the following events:
Activate
BeforeDoubleClick
BeforeRightClick
Calculate
Change
Deactivate
SelectionChange
Putting code in the Activate event will "do stuff" when the worksheet is opened.
-
Mar 21st, 2000, 02:28 PM
#3
Thread Starter
Member
Thanks
Thank you for your Help.
For me VBA is a new language, so i don't have a big knowledge about it.
Thanks
Scand
-
Mar 21st, 2000, 03:19 PM
#4
Lively Member
As a matter of fact, yes, there is a sub
(if present) that is automatically ran upon
opening an Excel file (except of course
if you disable macros)...
it is the sub procedure Auto_Open()
Code:
Sub Auto_Open()
msgbox "Welcome to my Excel file"
End Sub
-
Mar 21st, 2000, 04:00 PM
#5
Thread Starter
Member
That's exactly what i want.
Thank you very much.
That's exactly what i want.
When the Auto_Open function exists, then i think the Auto_Close function should also exists.
Thanks a lot
Scand
-
Mar 21st, 2000, 04:11 PM
#6
Thread Starter
Member
Auto_Open
Now with this function, it only works with my macro, when i open my macro, the code works, But i want, that the code works with evry file open in excel.
How can i make, that the function Auto_Open is called by evry Workbook i'll open?
Thanks
Scand
-
Mar 21st, 2000, 05:44 PM
#7
Lively Member
This depends on the version of Excel you're using.
*******************
1) Excel 5
a) Unhide your "Personal Macro Workbook"
(Use Window->Unhide command)
b) Write the sub Auto_Open()
c) Hide the "Personal Macro Workbook"
*******************
2) Excel 1997 and up...there is still
"help" on "Personal Macro Workbook" but
I can't unhide it. Anyway, here's a
crude way to go around this problem:
just save the Excel file containing
the sub Auto_Open() in the directory
"..\Office\XlStart"
NOTE: everytime you open an Excel file,
this file (the one you saved) is also
opened...sigh 
I have been trying to find a way other
than the step above but to no avail...
Please inform me if you have a solution
other than this...
*******************
[Edited by KenX on 03-22-2000 at 05:47 AM]
-
Mar 21st, 2000, 05:51 PM
#8
Lively Member
If you are using Excel 97 up,
make your sub procedure NOT in the
"ThisWorkbook" but rather, on a new
module (use Insert -> Module in the
VB Editor)
-
Mar 21st, 2000, 06:15 PM
#9
Thread Starter
Member
Thanks for your fast answer
My Macro is in the "Office\XlStart" path, the function "Auto_Open" is in a new module and i'm using Office 2000.
But it wont work with the Auto_Open, the code in this function appears only when i open my macro, not when i open an other Excel file. Why this?
I'm looking for an other solution, when i've found another one, i'll post it.
Thanks
Scand
-
Mar 21st, 2000, 10:31 PM
#10
New Member
I've managed to get this working - if you're using excel 97+
go to record macro, save in personal macro workbook, stop recording - edit the code and save. Every time you open excel it will perform the routine.
If you want to perform this when you open a new workbook from within the app - try the following - create another macro in your personal macro book, it should look something like this:
Workbooks.Add
then add your code after the above statement ie:
Workbooks.Add
Range("a1").Activate
ActiveCell.Value = "working"
then customise the buttons and assign this macro to the 'new' button. that should do it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|