By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,930 Members | 1,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,930 IT Pros & Developers. It's quick & easy.

Open Hyperlink Minimized or Hidden

P: 5
I'm trying to open an hyperlink, which is in fact an online streaming station, with a macro in Excel, like:
Expand|Select|Wrap|Line Numbers
  1. Sub MyMacro()
  2.  
  3. ActiveWorkbook.FollowHyperlink Address:="http://www.lmradio.net/streaming.html"
  4.  
  5. End Sub
But the page opens in full screen format and I want it to open minimized with the focus on the Excel sheet or hidden.

Can you help me?

Thanks.
Nov 8 '13 #1

✓ answered by zmbd

(*)(--- A thought, as I was replying, I hit on the AppActivate Application.Name while trying to set the focus back to your workbook (scroll to the bottom (^-^) ). You might just try sticking this after your current code and see if this works for you. I leave the rest of the reply just incase this doesn't suit your needs ---)

First look into that USER32.DLL
I don't do a lot of API calls; thus, I would rather have you find one that is tested and works instead of giving you bad information.

Once you understand how that API call works, then it should be straight forward from there...
You need the instance first... this will follow the same type of code as for Office Automation, you'll just be using the IE instead of Outlook or Excel as given in these examples... Office application automation
If this is going to be ran only on your PC then go in the VBE and set the reference as I gave you in my last post so that you have the intellisense and constants to work with for IE (and in the object browser you can see the object model! (The Internet Explorer Object Model This reference is to VBS so there are some slight differences; however, the model should be the same for our needs here)

Now using the same type of construct as in the automation article I linked you to, create your IE object (IEOBJ). Using the model information you should be able to set the navigation etc... Just make sure that you make the application object visible or you will have a huge mess on your hands as you open more and more IEOBJ without an easy way to close them!

Now, if I remember correctly, the IEOBJ.HWND is what you'll need to pass to the API call to minimize the window.

(*) Once you do that then in the code following the API call you'll need something that sets the focus back to your workbook... I would think: AppActivate Application.Name would do it if you have only one Workbook open then this should force the Excel forward. In fact, you may not even need the API call to minimize the IEOBJ (hmmm that may actually work under the KISS concept and what I should have started with upon reflection).

In anycase, let us know what happens.

Share this Question
Share on Google+
8 Replies


NeoPa
Expert Mod 15k+
P: 31,492
It doesn't appear that there is a parameter to specify that it be opened as minimised. Not sure if this is possible.
Nov 9 '13 #2

zmbd
Expert Mod 5K+
P: 5,397
If I remember correctly, IE is instanced as an object, then the URL is navigated to, then there is an API call to minimize the IEObject window.
Nov 11 '13 #3

P: 5
@zmbd
I'm sorry, can you be more specific? I don't really know how to put it any other way. The link opens the page correctly but the opened window comes to the the front of the Excel window and I want it minimized or in the background, keeping the focus on the spreadsheet. Of course, I can do it (minimize de window) manually, but then again in that case I wouldn't come here for help. Thanks, anyaway!
Nov 13 '13 #4

P: 5
@zmbd
You mean: object.ClientToWindow? I've tried but returns an error!
Nov 13 '13 #5

zmbd
Expert Mod 5K+
P: 5,397
jacaranda :

What you are trying to do is not routinely done; thus, the lack of an easy way to accomplish your goal. The routine situation is to open a hyperlinked file and set focus to it... otherwise, why open the object?

BTAIM:
Instancing an object can be done via either early or late binding.
Early binding: You will need to find the object library via the VBE/Tools/References that applies to object-model in question. In this case, Microsoft Internet Explorer Controls. This provides the constants and intelisense that we've all grown to love and depend on; however, if your next PC doesn't have this reference set, then the code chokes.

Hence:
Late Binding: In this case you will declare applicaiton level objects and will have to know the object-model and the constaints. There are some advantages for this method too; however, I leave that to the programmers to better explain than I would be able to do... for me the advantage is that I can build the application without having to worry about having the reference set out in the lab/client PC.

To instance the object, you need to first declare
DIM instanceofobject AS __
then set the object
set instanceofobject = ___

Notice I didn't fill in the blank... because what goes there depends on early or late binding.

In either case, once the IE object has been setup/created/instanced then you can tell it navigate to a webpage, etc... HOWEVER, for some reason one still can not minimize the window. You can however, leave it hidden - I warn you NOT to do that! If you leave it hidden, then it continues to run without any easy way to terminate the session, which takes up resources, and your end-users will hunt you down like a rabbid-zombie.

So how to minimize, You can set the height and widith of the IE-Obj, or you can do an API call (I think it is a User32.DLL; however, with the newer 64bit PC/OS I'm not absolutly sure about this anymore) passing on the handle of the open IE-Obj to the call to minimize its window.

You should be able to find some code snips that handle your situation.

-

I've also deleted one of your posts to this thread: It doesn't pay to antagonize members of any forum, be it here, "answers.*.com," "utter...," etc... You will find that the same people tend to be active and well respected members at all of these sites and many, many more; thus, you might find that no help from anyone anywhere by any site's membership.

Moderators such as Neopa and Myself, or the various Experts will tend to answer to the best of our knowledge - even if we are not sure of the answer, for mainly two reasons:
1) and formost: So that YOU the poster know that we've seen the thread. IMHO, there are very few things more frustrating than seeing a count of 200+ views and not a single answer or even so much as a Boo-I-Saw-You.
2) to start the conversation. Just because one of us doesn't have the exact answer doesn't mean what we do know wont jog the memory of someone else that will be able to provide an answer.

Finally, and with the utmost Respect, Bytes is neither a code writing nor homework service. Please keep in mind that moderators, experts, and others are un-paid volunteers that attempt to provide some help and guidance in-between our obligations to work and family.

Please be patient, we're doing the best we can to answer a question, especially on holidays and busy posting days.
Nov 13 '13 #6

P: 5
@zmbd
You are absolutely right: Why open it? Ok, this is the case:
The Excel spreadsheet shows me a Radio Station's complete schedule for the week. Several Excel functions tell me exactely which DJ is on the air any time, with his name, photo, program name and timetables. Until here all's well!
However when the workbook opens, the macro Workbook_Open is "fired", opening a link to the streaming html page, so that I can hear the radio station it in the background (preferably), but not in the foreground, because the window of the audiostream page comes in front of the spreadsheet. For this reason I want it minimized or in the background, so that I can see the information on the spreadsheet, without having to minimize it manually. Minimize, not close! If I close it I will lose the sound.
Any help would be much appreciated.
If you can't help, ok! Friends, as before!
FY
Nov 14 '13 #7

zmbd
Expert Mod 5K+
P: 5,397
(*)(--- A thought, as I was replying, I hit on the AppActivate Application.Name while trying to set the focus back to your workbook (scroll to the bottom (^-^) ). You might just try sticking this after your current code and see if this works for you. I leave the rest of the reply just incase this doesn't suit your needs ---)

First look into that USER32.DLL
I don't do a lot of API calls; thus, I would rather have you find one that is tested and works instead of giving you bad information.

Once you understand how that API call works, then it should be straight forward from there...
You need the instance first... this will follow the same type of code as for Office Automation, you'll just be using the IE instead of Outlook or Excel as given in these examples... Office application automation
If this is going to be ran only on your PC then go in the VBE and set the reference as I gave you in my last post so that you have the intellisense and constants to work with for IE (and in the object browser you can see the object model! (The Internet Explorer Object Model This reference is to VBS so there are some slight differences; however, the model should be the same for our needs here)

Now using the same type of construct as in the automation article I linked you to, create your IE object (IEOBJ). Using the model information you should be able to set the navigation etc... Just make sure that you make the application object visible or you will have a huge mess on your hands as you open more and more IEOBJ without an easy way to close them!

Now, if I remember correctly, the IEOBJ.HWND is what you'll need to pass to the API call to minimize the window.

(*) Once you do that then in the code following the API call you'll need something that sets the focus back to your workbook... I would think: AppActivate Application.Name would do it if you have only one Workbook open then this should force the Excel forward. In fact, you may not even need the API call to minimize the IEOBJ (hmmm that may actually work under the KISS concept and what I should have started with upon reflection).

In anycase, let us know what happens.
Nov 14 '13 #8

P: 5
Wow, thank you very much for your help. I promise you I will pay my utmost attention to the contents of the link you kindly sent me (IEOBJ). It'll be my first contact with this tool but I'm a fast learner. Thank You & all the best.
FY
Nov 15 '13 #9

Post your reply

Sign in to post your reply or Sign up for a free account.