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 Mar 22nd, 2002, 01:51 PM   #1
ctcoach141
New Member
 
Join Date: Mar 2002
Posts: 2
Default

Can someone tell me how to open an Internet Explorer page, select the entire page (ctrl a)copy it to the clip board (ctrl c) and return to EXCEL and paste (ctrl v) onto a worksheet. This, of course, all must be done from a signle click on an existing link in EXCEL.
ctcoach141 is offline   Reply With Quote
Old Mar 22nd, 2002, 02:15 PM   #2
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Do you mean you want a VBA macro to do all of this for you?

To literally do what you just described you're going to have to use "SendKeys" and "AppActivate". That's assuming you can hardcode the IE title bar text.
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old Mar 22nd, 2002, 02:45 PM   #3
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Mark, I too had the same idea to use sendkeys, but can't get it to work.

ActiveWorkbook.FollowHyperlink Address:="http://sports.yahoo.com/"
AppActivate "Microsoft Internet Explorer"
SendKeys "^A"
SendKeys "^C"
AppActivate "Microsoft Excel"
ActiveSheet.Paste

Any ideas...
Al Chara is offline   Reply With Quote
Old Mar 22nd, 2002, 03:53 PM   #4
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

You have to have the exact title in IE for this to work. Personally I would probably look into using API calls to get the handle of the IE window, but I don't have that code in work. Anyway, for AppActivate and Sendkeys to work you need to put pauses to let the computer catch up.

this code works for me:


ActiveWorkbook.FollowHyperlink Address:="http://www.soccernet.com/"
Application.Wait (Now + TimeValue("0:00:05"))
AppActivate "ESPN.com Soccernet: Home - Microsoft Internet Explorer provided by American Electric Power"
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "%E"
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "A"
Application.Wait (Now + TimeValue("0:00:03"))
SendKeys "^C"
Application.Wait (Now + TimeValue("0:00:01"))
AppActivate "Microsoft Excel - Book2"
Application.Wait (Now + TimeValue("0:00:05"))
ActiveSheet.Paste




_________________
[b] Mark O'Brien

[ This Message was edited by: Mark O'Brien on 2002-03-22 15:07 ]
Mark O'Brien is offline   Reply With Quote
Old Mar 22nd, 2002, 05:32 PM   #5
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

I got that to work too, but it still doesn't solve the problem of going to a different website. I'm still working on the API call part (I am trying to do it with the class name, not the title). Do you know what the class name is for Internet Explorer?

[ This Message was edited by: Al Chara on 2002-03-22 16:33 ]
Al Chara is offline   Reply With Quote
Old Mar 22nd, 2002, 06:00 PM   #6
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-03-22 16:32, Al Chara wrote:
I got that to work too, but it still doesn't solve the problem of going to a different website. I'm still working on the API call part (I am trying to do it with the class name, not the title). Do you know what the class name is for Internet Explorer?

[ This Message was edited by: Al Chara on 2002-03-22 16:33 ]
Class name for IE = IEFrame
How have you called the routine.....
Have you Shelled out to it.....??


Ivan
Ivan F Moala is offline   Reply With Quote
Old Mar 22nd, 2002, 07:27 PM   #7
Al Chara
MrExcel MVP
 
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
Default

Hey guys,

Try the following code:

Option Explicit

Public Const SW_RESTORE As Long = 9&
Public Const GW_CHILD As Long = 5&
Public Const GW_HWNDNEXT As Long = 2&

Declare Function GetDesktopWindow& Lib "user32" ()
Declare Function GetWindow& Lib "user32" (ByVal hWnd&, ByVal wCmd&)
Public Declare Function GetWindowText& Lib "user32" Alias "GetWindowTextA" _
(ByVal hWnd&, ByVal lpString$, ByVal cch&)
Declare Function ShowWindow& Lib "user32" (ByVal hWnd&, ByVal nCmdShow&)
Public Declare Function SetForegroundWindow& Lib "user32" (ByVal hWnd&)
Sub Main()
Const BaseCaption As String = "Internet Explorer"
Dim AppWindow&, sTemp$, StartTime, CycleTime

StartTime = Now
AppWindow = GetWindow(GetDesktopWindow(), GW_CHILD)
Do While CycleTime - StartTime < TimeValue("00:00:01")
sTemp = String$(180, False)
Call GetWindowText(AppWindow, sTemp, 179)
If InStr(sTemp, BaseCaption) Then
ActivateWindow AppWindow
Exit Sub
End If
AppWindow = GetWindow(AppWindow, GW_HWNDNEXT)
CycleTime = Now
Loop
MsgBox "The window is not open"
End Sub
Private Sub ActivateWindow(ByVal AppWindow&)
Call ShowWindow(AppWindow, SW_RESTORE)
Call SetForegroundWindow(AppWindow)
End Sub

It searches for the string "Internet Explorer" in the title of all open windows. If one of the titles is a match it activates that window, if there are now matches then it returns a message saying there were no matches. (Got some of the code floating on the internet)

_________________
Hope this helps.
Kind regards, Al.

[ This Message was edited by: Al Chara on 2002-03-22 18:28 ]
Al Chara is offline   Reply With Quote
Old Mar 22nd, 2002, 07:39 PM   #8
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Al....Great...thanks

Ivan
Ivan F Moala is offline   Reply With Quote
Old Mar 22nd, 2002, 07:44 PM   #9
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Al

I Changed Public const to include

Public Const SW_MAXIMIZE As Long = 3&

Plus I changed call to MAX window;

Call ShowWindow(AppWindow, SW_MAXIMIZE)


As I want the window Maximized.


Ivan

[ This Message was edited by: Ivan F Moala on 2002-03-23 03:22 ]
Ivan F Moala is offline   Reply With Quote
Old Mar 25th, 2002, 07:05 AM   #10
ctcoach141
New Member
 
Join Date: Mar 2002
Posts: 2
Default

Hey! Thanks for all the replies to my question! I'll let you know how it works!

Well, After working out some of the details that AppActivate and SendKeys works great! Thanks to Al & Brain!

Here's another problem for you. How can I send a URL string to the address window after navigating to a web page from an Excel Hyperlink?

[ This Message was edited by: ctcoach141 on 2002-03-26 06:08 ]
ctcoach141 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 07:05 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