VB: set ZOOM for new IE window, keep old zoom for next IE windows.

140123  VB: set zoom for new IE window, keep old zoom for next IE windows.
 
hi, i am trying to fix the zoom levels on some excel - ie code, that does not seem to keep the desired settings.
if operating a normal zoom at 75%, opening a coded page at 100% stops ability to open new pages/ tabs at 75%.
 
the answer i have is to open a 2nd ie window (only seems to work with 2nd macro below/ not a repeat of modified first macro for: 75% zoom).  then again,  with most attempts the symptom seems to be floating around on being able to get new window to a 75% zoom.  this answer stopped working as well.
 

PROBLEM:  trying to lock in this coded zoom for this instance & not interfere with other windows / tabs.
 (see 1st vb area labelled:  problem)
 
thanks in advance.
 
 
==========    DETAILS:
 
eg:
for a new page would like to change the setting using now: 75%  to 100% for that instance only, and to set the zoom back to 75%
 
 
SETTING NOTE:  seems to affect instance getting set to 100% to start with:
  INET OPTIONS:  adv tab, accessibility, CHECK: reset zoom for new windows & tabs.
  (does not seem to consider option for 1 time only use, at least as my code is set..)
 
 
MAIN PROBLEMS:   
  - pick zoom for this code (seems to work), keep previous zoom being used, for new windows.
  - stability? for want 100: some destination changes, requiring change zoom to 90 100 120.
    (i have tried to fix this by putting a standard zoom up front, at least fixes 75 of 75 problem).
    (need something, at end? to reset other windows back to, eg: 75% normally being used in this example).
 
  - you might see where i need to set zoom so it does not interfere with old/ new ie windows/ tabs.
'in leaving inet option off for: adv tab, reset zoom for new windows/ tabs:
'answer MAYBE to open different ie (by code) window, with no zoom set. (see 2nd macro below, ONLY ANSWER HAVE)

RUNNING this macro after 1st, seems to reset ability to open new ie windows/ tabs,
'without changing zooms manually.  something about this step clears the zoom 'lockout'.
 
----------
 
sub details: 
GEEZ PROBLEM: 
when open a window at 100%, others at 75/ want at 75 for new windows on normal browsing, but all new windows open at 100.
would like to reverse that around so all open at 75%, after the code with 100% runs.
  - tried open 2nd coded IE at 75%, got 75, but all new manual ie windows at 100, want 75.
  - trying changing setting in options back for reset zoom for new windows to unchecked.
  - now:  code will not set window to 100%.
 
OTHER PROBLEMS:
  - problem: if start at 75% (other windows), a new sube 100%/ another 75 or 90% comes up 75% of 75%..
  - the following line seems to work only in the area labelled:  LOWER SECTION.
    (if applies to isolation/ if then els: is there a variation of this line, to allow work in upper portion?
 
    .document.body.Style.Zoom = 0.75 'made note below: can i use this here..
 
  - small problem: if start macro from 'not' sheet1, how return to / stay at original sheet?
 
 
==========    MACRO 1
 
 
 
Sub openIE2()
    Const READYSTATE_COMPLETE& = 4&
    Dim sUrl As String, ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
   
    Worksheets(1).Select  'small problem: if start from different worksheet, how return there.
    With ie
      sUrl = InputBox("Enter Web Address", "Send IE to URL", GetClipboard)    'calls getclipboard
      'sUrl = InputBox("Enter Web Address", "Send IE to URL", "")
      'sUrl = InputBox("Enter Web Address", "Send IE to URL", "http://")
      'If LCase(Left(sUrl, 4)) = "http" Then
     
      If ActiveWindow.Zoom = 100 Then  'works
      'If LCase(Left(sUrl, 28)) = "https://encrypted.google.com" Then
       
        .AddressBar = False 'the good
        .MenuBar = False
        .Toolbar = False
        .TOP = 355&
        .Height = 245&
        .Left = 240&
        .Width = 395&
'Can i use a variation of this, here/ is that an idea?:
        '.document.body.Style.Zoom = 0.75  'ERROR, modify to work here or bad idea?
       
      Else
        .AddressBar = False 'the bad  (GOOD SIZE) fix zoom
        .MenuBar = False
        .Toolbar = False
        .TOP = 305&
        .Height = 295&
        .Left = 220&
        .Width = 465&
        '.document.body.Style.Zoom = 1     'ERROR
      End If
        .navigate sUrl
        .resizable = True
       
'LOWER LEVEL:  WHICH OF THESE ARE PREFERRED? (do while/ while not):       
   
    'Do While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Loop
    While Not .readyState = READYSTATE_COMPLETE   'ie1a ver
    DoEvents
    Wend

'<< PROBLEM AREA WORKING ON:
'INET OPTIONS: adv tab, uncheck: reset zoom level for new windows & tabs,
'even if just have set zoom to 100 (1)/ turn off .75, nothing happens here, when open new window (with 1 code opened window: open).
'answer MAYBE to open different ie (by code) window, with no zoom set. (see 2nd macro below)
       
        '.document.body.Style.Zoom = 0.75      'ZOOM  (1=100%), 1 1st, else .75 of .75 on 2nd.. opening
        If ActiveWindow.Zoom < 100 Then        'MsgBox ("yes1")
        'If LCase(Left(sUrl, 28)) = "https://encrypted.google.com" Then

'PROBLEM:  trying to lock in this coded zoom for this instance & not interfere with others.
        .document.body.Style.Zoom = 1  'some intermittent probs actually getting 100%
       
        Else
        'MsgBox ("yes2")
        End If
       
       
        '.Document.parentWindow.scroll 0&, 200&  'SCROLL  IN & DN,  horiz (right) & vert (down)
        .Visible = True
    End With
    Set ie = Nothing
End Sub

 

'==========    RUNNING this macro after 1st, seems to reset ability to open new ie windows/ tabs,
'without changing zooms manually.  something about this step clears the zoom 'lockout'.

 

Sub openIE1a()   'GOOG MAIN:  KEEP  (full size page)
    Const READYSTATE_COMPLETE& = 4&
    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .AddressBar = True
        .MenuBar = True
        .Toolbar = True
        .TOP = 0&
        .Height = 862&
        .Left = 0&
        .Width = 1300&      '1280 norm / any more for max scrn width
        .navigate "https://encrypted.google.com/search?complete=0&num=100&hl=en&safe=off&q=%test%22"  'keep
        .resizable = True
    While Not .readyState = READYSTATE_COMPLETE
    DoEvents
    Wend
        '.document.parentWindow.scroll 0&, 0&     'SCROLL  IN & DN,  horiz (right) & vert (down)
        '.document.body.Style.Zoom = 0.75
        .Visible = True
    End With
    Set ie = Nothing
End Sub

 

Question Info


Last updated February 27, 2018 Views 552 Applies to: