1、首先在开发工具中打开VBA编辑器
2、在单元格区域当中输入一些内容作为例子
3、在VBA编辑器中插入模块
4、在模块当中输入如下代码,然后运行Private Declare Function 掂迎豢畦FindWindow Lib "use32" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long,ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Declare Function SetWindowRgn Lib "use32" (ByVal hWnd As Long,ByVal hRgn As Long, ByVal bRedraw As Boolean) As LongPrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Sub UserForm_Click()Unload Me '单击关闭窗体End SubPrivate Sub UserForm_Initialize() Dim hWnd As Long, new_rgn As Long If Val(Application.Version) < 9 Then '如果是Windows 2000以下的系统 hWnd=FindWindow("ThunderXFrame", Me.Caption) '获取窗口句柄ThunderXFrame Else '否则 hWnd=FindWindow("ThunderDFrame", Me.Caption) '获取窗口句柄ThunderDFrame End If new_rgn=CreateRectRgn(3, 29, (Me.Width * 1.33)-2, (Me.Height * 1.33)-2) '创建一个由四个数据点描述的矩形区域 SetWindowRgn hWnd, new_rgn, True '按前面定义的区域重绘窗体形状 Call DeleteObject(new_rgn)End Sub
5、用快捷键F5运行窗体,窗体仅仅显示图片区,标题及边框已隐藏。隐藏边框前的窗体如图13.10所示,隐藏边框后的窗体如图