香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 22nd Jan 2006, 15:14 PM | Office Application | (1356 Reads)

Excel 每次打開時高寬自動設為螢幕大小的 80%

Private Sub Workbook_Open()
     SetXLResolution
End Sub

Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1


Sub SetXLResolution()
Dim VWidth As Integer
Dim VHeight As Integer
' 高寬自動設為螢幕大小的 80%
VWidth = GetSystemMetrics(SM_CXSCREEN)
VHeight = GetSystemMetrics(SM_CYSCREEN)

With Excel.Application
     .WindowState = xlNormal ' 先將窗口還原
     .Width = VWidth * 0.8 * 0.75 ' Points (~ 0.75 pixels)
     .Height = VHeight * 0.8 * 0.75
     .Left = VWidth * 0.1 * 0.75
     .Top = VHeight * 0.1 * 0.75
End With
End Sub

 

 

請參看 將 Excel, Word 及 OutLook 並排

Last update: 22 Jan 2006