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 14th, 2002, 12:34 PM   #1
Anzulo
New Member
 
Join Date: Feb 2002
Location: Queretaro, Mex.
Posts: 19
Default

Hi guys,
I hope you can help. This is the first time i post something although i see all the posts every day since 2 or 3 moths ago.
The situation is that every day i need to e-mail a report to my boss, this report reflects the status of the activities being developed by the team (around 40 guys). The data i analyse to reflect this status is stored in a database. This DB can be accesed two ways, one is using the designed user interface which is very useful because yo only enter your credentials and then go to the "Search Screen" where you enter all the criteria to look for the information you need, actually it allows you to create templates so every day you go and chose the same template and run the search, once you have the data the system allows you to save it as a CVS file.
The other way to acces the DB is via MS ACCES, in this case you also enter your credentials and go to "Queries", of course you can have a "Query" already customized so you can use it every day.
I have created a macro in Excel to process this data and send it to my boss automatically in an organized format so he can easily read it (that's the way my boss works!!).
This is the process i follow to send this daily report to him:
1.- Go to the DB(the one which has the user interface)and insert my LOGONID and PASSWORD.
2.- Go to the search menu and ENTER THE CRITERIA for the query.
3.- Got the data displayed in the screen.
4.- Go to the Commands menu and CHOSE "Save to file".
5.- I SPECIFY THE PATH where i want the data be saved AND ALSO THE FILE NAME which is the "today" date.
6.- I exit from the DB.
7.- Open the workbook which contains the macro.
8.- Open the CSV file and copy the data from here to the one which contains the macro.
9.- Run the macro which makes my boss be happy with this report in his inbox.

As you can see there are some steps before running the macro. I would like to remove those steps and only run a macro which could do all this process for me every day.
My problem is that my VBA knowledge does not allows me to write the code to go to the DB, enter my LOGONID and PASSWORD, specify the criteria for the query, tell the system to save the data and import it to the one which has the macro to send the report to my boss.
Do you have any idea how to tell the system go to the DB, enter the LOGONID and PASSWORD, search the data, save it and importe it to the book with the macro?

I hope i had expressed my self in a comprehensive way and also that you can help me.

Please if you need any other information let me know it.

Thanks in advance.
Respectfully.
Anzulo is offline   Reply With Quote
Old May 14th, 2002, 12:47 PM   #2
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

Anzulo,

I've done some work with ODBC calls to an access (.mdb) database, but something tells me this is not going to help you. If your database is a .mdb, let me know and I'll give it a go.

If this is not the case, you may want to look into using the sendkeys function to "automate" the login. Look at help files for this for more info (I have not done this for a while). If you don't have an ODBC driver for the database, you will probably resort to sendkeys in some way.

Maybe someone more familliar with this thing could help more...

K
kkknie is offline   Reply With Quote
Old May 14th, 2002, 02:15 PM   #3
Anzulo
New Member
 
Join Date: Feb 2002
Location: Queretaro, Mex.
Posts: 19
Default

KKKnie, Thanks for replying.
I have checked the database and this is what i found:
I opened the DB using MSACCES and in the "TABLES" menu i am able to see all the available tables to be used. I also see the one that i am interested in, i displyed all details for it and i saw the table name, the description, the modified date, the created date and the TPYE which says TABLE: LINKED ODBC.
In the other hand i remember when i "instaled" this DB in my PC i had to add or modify something in the ODBC Data Source Administrator. Now if go to this ODBC Data Source Administrator it says the DB name and the DRIVER which says Sybase System 11.

Now i hope this gives you more information about the DB i am using. Please reply.

PD> You are talking about "sendkey", is this an object or a method??
Anzulo is offline   Reply With Quote
Old May 15th, 2002, 06:57 AM   #4
Anzulo
New Member
 
Join Date: Feb 2002
Location: Queretaro, Mex.
Posts: 19
Default

Still need help / suggestions about this.
Any help is welcome.

Thanks in advance

Quote:
On 2002-05-14 11:47, kkknie wrote:
Anzulo,

I've done some work with ODBC calls to an access (.mdb) database, but something tells me this is not going to help you. If your database is a .mdb, let me know and I'll give it a go.

If this is not the case, you may want to look into using the sendkeys function to "automate" the login. Look at help files for this for more info (I have not done this for a while). If you don't have an ODBC driver for the database, you will probably resort to sendkeys in some way.

Maybe someone more familliar with this thing could help more...

K
Anzulo is offline   Reply With Quote
Old May 15th, 2002, 08:08 AM   #5
kkknie
Board Regular
 
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
Default

Sendkeys is a method that simply mimics keystrokes. I think
you might be able to automate the tasks required to open your
database, enter login id and password, enter your criteria,
save to a file and exit. The last three items on your list
should be able to be done using other methods.

This is what you must do. Go through all of the steps
you use to open, search, save and exit making sure to
use only keystrokes (no mouse input). Write these down
and then set up a macro in excel to mimic them.

I would recommend starting slowly (i.e. first just open
the database, then when that works, enter your id, etc.).
The excel help for sendkeys should assist in getting
all of the special keystrokes you need (like enter, alt,
arrow up, arrow down, etc.).

One thing about the sendkeys method is that it can get
ahead of itself. To keep this from happening, I always
put a bunch of waits between each keystroke. It takes
longer, but works better.

Here is an example of how I open a password protected file
in msaccess (note that this board converts
1 backslash into 2, so adjust accordingly:

Sub OpenDatabase1()

Shell ("D:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE c:db2.mdb")
sleep (3)
SendKeys ("p")
sleep (1)
SendKeys ("a")
sleep (1)
SendKeys ("s")
sleep (1)
SendKeys ("s")
sleep (1)
SendKeys ("1")
sleep (1)
SendKeys ("2")
sleep (1)
SendKeys ("3")
sleep (1)
SendKeys ("~")

End Sub

Sub sleep(i)

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + i
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

End Sub

Try working on it for a while and let me know how it is going.

[ This Message was edited by: kkknie on 2002-05-15 07:10 ]
kkknie is offline   Reply With Quote
Old May 15th, 2002, 08:17 AM   #6
klb
Board Regular
 
Join Date: Apr 2002
Location: Minnesota
Posts: 821
Default

Have you tried to use Data, Get External Data from within Excel?

You will need to have MSquery installed and the database set up as a Data source.

But you can do it all from within Excel.
klb 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 06:59 PM.


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