能不能在VB程序中打开一个EXCEL文件,要求打开的文件是VB程序的子窗口

来源:百度知道 编辑:UC知道 时间:2024/07/02 06:38:14

代码如下。
===================
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
Dim xls As Object, wbk As Object, l As Long
Set xls = CreateObject("excel.application")
xls.Visible = True
Set wbk = xls.workbooks.Add
l = FindWindow(vbNullString, "microsoft excel - book1")
SetParent l, hWnd
End Sub