Unable to position and resize an Excel Window With VBA

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Please consider this code. I am looking for a solution to resolve the "Unable to set the Top property of the Window class" error I get with theline in red.
Rich (BB code):
Public Sub ReadingView()
'Stop
With Application
  
 With ActiveWorkbook
  ' store current ActiveWorkbook settings
  View.drawingobjects = .DisplayDrawingObjects
  '.DisplayDrawingObjects = xlHide
 End With
   
 With ActiveWindow
  ' store current ActiveWindow settings
  View.headings = .DisplayHeadings
  View.gridlines = .DisplayGridlines
  View.hscrollbar = .DisplayHorizontalScrollBar
  View.vscrollbar = .DisplayVerticalScrollBar
  View.wkbtabs = .DisplayWorkbookTabs
  View.windowstate = .windowstate
  ' set
  .DisplayHeadings = False
  .DisplayHorizontalScrollBar = False
  .DisplayVerticalScrollBar = False
  .DisplayWorkbookTabs = False
  .DisplayGridlines = False
  '.windowstate = xlNormal
  .Top = 25
  .Left = 25
  .Width = 500
  .Height = 250
  
 End With
 
 ' set
 .ExecuteExcel4Macro _
  "SHOW.TOOLBAR(""Ribbon"",False)"
 
 ' store current Application Settings
 View.formulabar = .DisplayFormulaBar
 View.statusbar = .DisplayStatusBar
 'set
 .DisplayFormulaBar = False
 .DisplayStatusBar = False
 
End With
  
End Sub

Note:
The activeworkbook is the second of two workbooks currenly open. It is properly being recognized as the "Activeworkbook"
This procedure is executed as part of the activeworkbook's activation of worksheet "Form"

Code in workbook had had opened this 2nd workbook and kept it hidden until at some time, code in workbook 1 revealed the hidden workbook, and activated worksheet "Form" thus triggering this code. The preferred outcomne is to have a size reduced workbook 2 window in front of workbook 1. The user then uses the interface provided in worksheet "Form" of workbook 2 to compile infomation needed for the code to proceed in workbook 1. The code in workbook 1 is stopped (with a stop command after worksheet "Form" had been activated) until data is entered. Watch for my next question ... how to resume stoped code?

I'm sure much of this can be avoided by using a userform in workbook 1. My logic is why reinvent something already working to do the same thing in another workbook (although not as a userform)? I may soon have an answer to that question.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Depending on the windowstate it is not always possible to set size and position. Try this as an experiment:

VBA Code:
           '.windowstate = xlNormal
            With Application.Windows
                '.Arrange ArrangeStyle:=xlVertical
                '.Arrange ArrangeStyle:=xlTiled
                '.Arrange ArrangeStyle:=xlHorizontal
                .Arrange ArrangeStyle:=xlCascade
            End With
            .Top = 25
            .Left = 25
            .Width = 500
            .Height = 250
 
Upvote 0
Solution
Hello, rlv01. I appreciate your help. Thank you, it seems to be the solution.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top