Everyone in the use of Excel or Excel platform, will face such a problem, application development, found the client's screen resolution is different, lead to show results, and how to better solve this problem? Only a few lines of simple VBA code can,
Declare the Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Sub auto_open ()
Application. ScreenUpdating=False
Dim X As Long, Y As Long
X=GetSystemMetrics32 (0) 'width (pixels)
Y=GetSystemMetrics32 (1) 'height (pixels)
Dim I, j, k, l
For j=3 To 32 ' ' ' ' 'For a maximum of information area of the column, need To change according To actual condition
J, k=Cells (2) ColumnWidth
Cells (2, j)=k * X/1024 'ColumnWidth values divided by the width of the current resolution 1024102, in order to establish when the template is just screen size value,
Next
For I=5 To 37 ' ' ' ' '37 For the maximum of information area, need To change according To actual condition
L=Cells (I, 3). RowHeight
Cells (I, 3). The RowHeight=l * Y/768
Next
' ' ' ' 'to change the value of each category by the for loop, but in this case, not to change the font, the result is bad also can by controlling the scaling method ActiveWindow. Zoom=100 * X/1024 to determine the current resolution is the width of the value and 1024 the proportion of relations, Zoom in on the corresponding proportion, Application. ScreenUpdating=True
End Sub