开发者

How to maximize a browser from MS Access programmatically?

My purpose for maximizing the browser is to provide a connected and seamless experience for the user from their MS Access application to their web application. For this reason I am looking for a solution which maximizes the same instence of the web browser being controlled via the MS Access application.

I start by doing something like this:

Dim IE As InternetExplorer
Set IE = New InternetExplorer
IE.Navigate2 "\\File Location\index.html"
IE.Document.all("txtSearchKey").innertext = SearchKeyValue
IE.Document.all("btnSearchForKey").Click
IE.Visible = Tru开发者_高级运维e
Set IE = Nothing

But what I want to do is ensure every time this code is run, the browser is also maximized.

What is the best way to accomplish this programmatically?


I found the following windows API call to be particularly useful in setting the window size of the web browser. This looks like it could also be used with any other windows application for which the window handle is available to as well.

Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
            (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2

So, by putting this together at the end of the code in the question above, I made this function call to set the browser size to maximized:

apiShowWindow IE.hwnd, SW_MAXIMIZE


If you call the browser using the Shell statement, you can use the vbMaximizedFocus windowstyle. Example with Windows Explorer:

Shell "explorer.exe", vbMaximizedFocus
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜