PDA

View Full Version : Manipulate VBE Window



arkusM
12-09-2009, 10:01 AM
I have found and have been using the following code to set my Excel application window size on a dual screen setup.


Sub VBAVirtualScreen()
With Application
.WindowState = xlNormal
.Left = 0
.Top = 0
.Width = GetSystemMetrics(SM_CXVIRTUALSCREEN) - 1787
.Height = GetSystemMetrics(SM_CYVIRTUALSCREEN) - 275
End With
End Sub


I would like to set the VBE window size as well... however I cannot seem to find the appropriate code. I have tried using VBIDE or Application.VBE but with no success :banghead: . The "help" file on Application is no help.

Cheers.
Mark

Bob Phillips
12-09-2009, 11:31 AM
Have youtried



Sub VBAVirtualScreen()
With Application.VBE
.WindowState = xlNormal
.Left = 0
.Top = 0
.Width = GetSystemMetrics(SM_CXVIRTUALSCREEN) - 1787
.Height = GetSystemMetrics(SM_CYVIRTUALSCREEN) - 275
End With
End Sub

arkusM
12-09-2009, 11:37 AM
Yes i did. I just went and reran the macro after reopening Excel to get the error code and a different error came up after running the code for the "first" time after opening. This time I got a "Programmictic access to Visual Basic Project is not trusted" error.

Other wise I get a "Method 'VBE' of object '_Application' failed"

Bob Phillips
12-09-2009, 11:39 AM
To overcome thgis, goto Tools>Macro>Security, select the Trusted Publishers tab, and check it.

arkusM
12-09-2009, 11:53 AM
I Trusted Access to VB project now I get:
Runtime error '438':
Object doesn't support this propery or method

I have "Microsoft Visual Basic for Apps Extensibiility 5.3" ref'd

arkusM
12-09-2009, 02:10 PM
Got It! Needed to add the red bits.


With Application.VBE.MainWindow
.WindowState = vbext_ws_Normal
End With



Thanks for the help xld you got me going the right directions, well at least stopped me from spinning in circles!! LOL