Foxtable(狐表)用户栏目专家坐堂 → 小白请教WebBrowser和excel问题


  共有2176人关注过本帖树形打印复制链接

主题:小白请教WebBrowser和excel问题

帅哥哟,离线,有人找我吗?
tcmhl
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:159 积分:1718 威望:0 精华:0 注册:2014/9/1 0:35:00
小白请教WebBrowser和excel问题  发帖心情 Post By:2017/5/23 12:51:00 [只看该作者]

 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)

谢谢!

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/5/23 14:14:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
tcmhl
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:159 积分:1718 威望:0 精华:0 注册:2014/9/1 0:35:00
  发帖心情 Post By: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

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



 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By: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
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:159 积分:1718 威望:0 精华:0 注册:2014/9/1 0:35:00
  发帖心情 Post By: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



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



 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/5/23 17:16:00 [只看该作者]

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

 

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

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
tcmhl
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:159 积分:1718 威望:0 精华:0 注册:2014/9/1 0:35:00
  发帖心情 Post By:2017/5/23 17:39:00 [只看该作者]

感谢!回去试试

 回到顶部