MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 10th, 2002, 04:20 AM   #1
Lo Lun To
 
Join Date: May 2002
Posts: 8
Default


I see a great number of requests on this board for VBA code that can be obtained merely by running the macro recorder.

Before posting requests for macro code, try the macro recorder.
This may result in your question to this board being unnecessary.
In addition, your VBA knowledge is likely to be more enhanced by having found the code yourself, rather than being supplied by others.

Persons who are experienced with VBA frequently use the macro recorder to get code.
Many of the answers supplied to the many simple VBA questions on this board are most likely obtained from the macro recorder.


Lo Lun To is offline   Reply With Quote
Old May 10th, 2002, 07:45 AM   #2
jkpd2000
Board Regular
 
Join Date: May 2002
Posts: 91
Default

Hi,

After i read your message i tried and it worked. But my question is can you tell us who are inexperienced a small vbscript code example , how to place the code , where to place and how to run it.

For example. I have created a macro to open a text file and save it as excel.

Now i want to run it automatically every day.
What should i do ? Thanks in advance.
jkpd2000 is offline   Reply With Quote
Old May 10th, 2002, 08:22 AM   #3
jkpd2000
Board Regular
 
Join Date: May 2002
Posts: 91
Default

Hi ,

I am recording a macro. and after i exit from excel the macro is getting deleted . how to retain that ? any thoughts?
jkpd2000 is offline   Reply With Quote
Old May 10th, 2002, 08:23 AM   #4
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

How would you like this to run automatically? When the workbook is opened or something like that? (Note: You're going to have to at least open the workbook to get code to run)
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old May 10th, 2002, 08:28 AM   #5
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

jkpd2000,

If you exit without saving the workbook it will get deleted (since you are recording it into the workbook). If you want to have it available to all workbooks you open, you will need to save it into your personal macro workbook (by changing the drop-down list when you start recording the macro).

K
kkknie is offline   Reply With Quote
Old May 10th, 2002, 08:36 AM   #6
jkpd2000
Board Regular
 
Join Date: May 2002
Posts: 91
Default

Hi,
That worked. thanks.

Now i need to run it automatically. i.e.
i created a personal macro. i saved it.
But every day i have to open a file, run that macro and save that file as a different file. it should do automatically.

is there a way ?

thanks in advance
jkpd2000 is offline   Reply With Quote
Old May 10th, 2002, 08:45 AM   #7
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Quote:
(Note: You're going to have to at least open the workbook to get code to run)
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old May 10th, 2002, 08:49 AM   #8
jkpd2000
Board Regular
 
Join Date: May 2002
Posts: 91
Default

i think i can open the work book from a batch file. my question is how to run the macro i created to run automatically. is there any option i can specify in batchfile itself to run that macro as soon as it opens the workbook ?
jkpd2000 is offline   Reply With Quote
Old May 10th, 2002, 08:56 AM   #9
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

That's what I was asking you before.

Ok:

1. Open you workbook
2. Hit ALT + F11 to open the VBE
3. Double Click on "ThisWorkbook" in the project explorer pane
4. On the combobox on the left hand side at the top of the code pane, select "WorkBook", this code should then appear:


Private Sub Workbook_Open()

End Sub


5. Insert the name of your macro between these two lines of code. e.g. if it's called "Sub Macro123()" put this:


Private Sub Workbook_Open()
Macro123
End Sub


6. Save the workbook and close.

Whenever the workbook is opened, this code will run. However, unless your security level is set lower than "Medium" or you have some kind of digital signature, your workbook will always throw up the "Enable Macros?" box when the worksheet is opened.

_________________
[b] Mark O'Brien

[ This Message was edited by: Mark O'Brien on 2002-05-10 07:56 ]
Mark O'Brien is offline   Reply With Quote
Old May 10th, 2002, 09:19 AM   #10
jkpd2000
Board Regular
 
Join Date: May 2002
Posts: 91
Default

At last , I am getting some hope.

Mark, I did the same way you told.

didn't work.

1. i did a macro with recorder called test and placed just as you said.

Private Sub Workbook_Open()
test
End Sub

it is giving error.

sub or function not defined. do i need to paste the macro code somewhere?

2. how to open this workbook from scheduler or batch file.?

jkpd2000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:10 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes