以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  小白请教WebBrowser和excel问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=101002)

--  作者:tcmhl
--  发布时间:2017/5/23 12:51:00
--  小白请教WebBrowser和excel问题
 Dim web As Windows.Forms.WebBrowser
web = Forms("a").Controls("WebBrowser1").baseControl
AddHandler web.DocumentCompleted,addressof WebBrowser1_DocumentCompleted
web.Navigate(Vars("PATH"))

这样打开excel后,用什么语句对他进行操作??

比如:Ws.Protect(DrawingObjects:=True)

谢谢!

--  作者:有点色
--  发布时间:2017/5/23 14:14:00
--  

 参考

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=100919&skin=0

 


--  作者:tcmhl
--  发布时间:2017/5/23 14:19:00
--  
Dim web As Windows.Forms.WebBrowser
web = Forms("a").Controls("WebBrowser1").baseControl
AddHandler web.DocumentCompleted,addressof WebBrowser1_DocumentCompleted
web.Navigate(Vars("PATH"))

Dim oDocument As object = axWebBrowser.Gettype().InvokeMember("Document", System.Reflection.BindingFlags.GetProperty, Nothing, axWebBrowser, Nothing)
Dim oApplication As object = axWebBrowser.Gettype().InvokeMember("Application", System.Reflection.BindingFlags.GetProperty, Nothing, oDocument, Nothing)
oDocument.Sheets(1).range(1).Select

这样写好像报错哦  图片点击可在新窗口打开查看



--  作者:有点色
--  发布时间:2017/5/23 14:26:00
--  

axWebBrowser = Nothing
Dim web As Windows.Forms.WebBrowser
web = e.form.Controls("WebBrowser1").baseControl
AddHandler web.DocumentCompleted,addressof WebBrowser1_DocumentCompleted
web.Navigate(ProjectPath & "book6.xls")

Do While axWebBrowser Is Nothing
    Application.Doevents
Loop
Dim oDocument As object = axWebBrowser.Gettype().InvokeMember("Document", System.Reflection.BindingFlags.GetProperty, Nothing, axWebBrowser, Nothing)
Dim oApplication As object = axWebBrowser.Gettype().InvokeMember("Application", System.Reflection.BindingFlags.GetProperty, Nothing, oDocument, Nothing)
oDocument.WorkSheets(1).range("2:2").Select


--  作者:tcmhl
--  发布时间:2017/5/23 16:14:00
--  
 再请教下啊。。如果我有两个WebBrowser打开两个excel

axWebBrowser1 = Nothing
Dim web1 As Windows.Forms.WebBrowser
web1 = e.form.Controls("WebBrowser1").baseControl
AddHandler web1.DocumentCompleted,addressof WebBrowser1_DocumentCompleted
web1.Navigate(ProjectPath & "1.xls")

Do While axWebBrowser1 Is Nothing
    Application.Doevents
Loop
Dim oDocument1 As object = axWebBrowser1.Gettype().InvokeMember("Document", System.Reflection.BindingFlags.GetProperty, Nothing, axWebBrowser1, Nothing)
Dim oApplication1 As object = axWebBrowser1.Gettype().InvokeMember("Application", System.Reflection.BindingFlags.GetProperty, Nothing, oDocument1, Nothing)
oDocument1.WorkSheets(1).range("2:2").Select




axWebBrowser2 = Nothing
Dim web2 As Windows.Forms.WebBrowser
web2 = e.form.Controls("WebBrowser2").baseControl
AddHandler web1.DocumentCompleted,addressof WebBrowser2_DocumentCompleted
web2.Navigate(ProjectPath & "2.xls")

Do While axWebBrowser2 Is Nothing
    Application.Doevents
Loop
Dim oDocument2 As object = axWebBrowser2.Gettype().InvokeMember("Document", System.Reflection.BindingFlags.GetProperty, Nothing, axWebBrowser2, Nothing)
Dim oApplication2 As object = axWebBrowser2.Gettype().InvokeMember("Application", System.Reflection.BindingFlags.GetProperty, Nothing, oDocument2, Nothing)
oDocument2.WorkSheets(1).range("2:2").Select



好像不行 图片点击可在新窗口打开查看



--  作者:有点色
--  发布时间:2017/5/23 17:16:00
--  

 测试了一下,不行。它们共用一个excel进程,相互影响。

 

 如果确实要用两个,建议使用嵌入的方式处理。

 

下载信息  [文件大小:308.0 KB  下载次数:3]
图片点击可在新窗口打开查看点击浏览该文件:嵌入exe程序到自己的窗口.table


--  作者:tcmhl
--  发布时间:2017/5/23 17:39:00
--  
感谢!回去试试