怎么在VB窗体里显示一个EXCEL工作表.然后
展开全部
1、调用excel对象打开工作表;
Dim oe As New Excel.Application
Dim ow As Workbook
Dim os As Worksheet
Set ow = oe.Workbooks.Add
Set os = ow.Worksheets(1)
oe.Visible = True
2、取消excel窗体的标题栏、菜单栏、工具栏;
For Each bar In Application.CommandBars
If Not bar.BuiltIn And Not bar.Visible Then bar.Delete
Next
Application.CommandBars("Worksheet Menu Bar").Position = msoBarFloating
Application.CommandBars("Worksheet Menu Bar").Left = -Application.CommandBars("Worksheet Menu Bar").Width + 1
Application.CommandBars("Worksheet Menu Bar").Top = -Application.CommandBars("Worksheet Menu Bar").Height + 1
3、将excel窗体设置为某窗体的"子窗体",调整大小并放在合适位置
Dim IStyle As Long
IStyle = GetWindowLong(hwnd, GWL_STYLE)
IStyle = IStyle And Not WS_CAPTION And Not WS_EX_APPWINDOW
SetWindowLong hwnd, GWL_STYLE, IStyle
ShowWindow hwnd, SW_SHOW
DrawMenuBar hwnd
SetParent hwnd, Form1.hwnd
Dim oe As New Excel.Application
Dim ow As Workbook
Dim os As Worksheet
Set ow = oe.Workbooks.Add
Set os = ow.Worksheets(1)
oe.Visible = True
2、取消excel窗体的标题栏、菜单栏、工具栏;
For Each bar In Application.CommandBars
If Not bar.BuiltIn And Not bar.Visible Then bar.Delete
Next
Application.CommandBars("Worksheet Menu Bar").Position = msoBarFloating
Application.CommandBars("Worksheet Menu Bar").Left = -Application.CommandBars("Worksheet Menu Bar").Width + 1
Application.CommandBars("Worksheet Menu Bar").Top = -Application.CommandBars("Worksheet Menu Bar").Height + 1
3、将excel窗体设置为某窗体的"子窗体",调整大小并放在合适位置
Dim IStyle As Long
IStyle = GetWindowLong(hwnd, GWL_STYLE)
IStyle = IStyle And Not WS_CAPTION And Not WS_EX_APPWINDOW
SetWindowLong hwnd, GWL_STYLE, IStyle
ShowWindow hwnd, SW_SHOW
DrawMenuBar hwnd
SetParent hwnd, Form1.hwnd
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询