word右键添加百度谷歌搜索,word右键添加打开某个文件夹选项

http://wenku.baidu.com/view/56b5f87aa26925c52cc5bf14.html?st=1免积分下载教程

word -工具- 宏- 创建 - 添加下面代码,文件夹路径和浏览器路径自己修改




Private Sub Document_Close()

    On Error Resume Next
    Application.CommandBars("Text").Controls("Google搜索").Delete   '恢复原有菜单
    Application.CommandBars("Text").Controls("Baidu搜索").Delete   '恢复原有菜单
    Application.CommandBars("Text").Controls("work").Delete   '恢复原有菜单
    Application.CommandBars("Text").Reset '重新设置右键菜单,彻底恢复默认设置
End Sub


'----------------------
Private Sub Document_Open()
    On Error Resume Next
    Dim BtnGoogle As CommandBarButton
    Dim BtnBaidu As CommandBarButton
    Dim Btnfile As CommandBarButton
    Application.CommandBars("Text").Controls("Google搜索").Delete   '预防性删除
    Application.CommandBars("Text").Controls("Baidu搜索").Delete   '预防性删除
    Application.CommandBars("Text").Controls("work").Delete   '预防性删除
    Application.CommandBars("Text").Reset '重新设置右键菜单,彻底恢复默认设置
       
   
    Set BtnBaidu = Application.CommandBars("Text").Controls.Add(Type:=msoControlButton, Before:=1) '第一项
    Set BtnGoogle = Application.CommandBars("Text").Controls.Add(Type:=msoControlButton, Before:=2) '第二项
    Set Btnfile = Application.CommandBars("Text").Controls.Add(Type:=msoControlButton, Before:=3) '第三项
    With BtnGoogle
      .Caption = "&Google搜索" '命令名称
      .FaceId = 86             '命令的FaceId,字母G
      .Visible = True           '可见
      .OnAction = "GoogleSearch"       '指定响应过程名
    End With
    With BtnBaidu
      .Caption = "&Baidu搜索" '命令名称
      .FaceId = 81             '命令的FaceId
      .Visible = True           '可见
      .OnAction = "BaiduSearch"       '指定响应过程名
    End With
    With Btnfile
      .Caption = "&work" '命令名称
      .FaceId = 85             '命令的FaceId
      .Visible = True           '可见
      .OnAction = "CommandButton1_Click"       '指定响应过程名
    End With
End Sub


'----------------------
Sub GoogleSearch()
    Dim sSearch$, sSel$
    sSel = Trim(Selection.Text)
                                                                                                                                      
      sSearch = "C:\Documents and Settings\Administrator\Local Settings\Application Data\360Chrome\Chrome\Application\360chrome.exe ""http://www.google.com.hk/search?client=Juncox&hl=zh-CN&q=" & sSel & """"    '两种形式结果是一致的
    '  sSearch = "explorer " & Chr(34) & "http://www.google.cn/search?client=Juncox&hl=zh-CN&q=" & sSel & Chr(34)
      Shell sSearch
    
End Sub


Sub BaiduSearch()
    Dim sSearch$, sSel$
    sSel = Trim(Selection.Text)
    
      sSearch = "C:\Documents and Settings\Administrator\Local Settings\Application Data\360Chrome\Chrome\Application\360chrome.exe ""http://www.baidu.com/baidu?tn=Juncox&word=" & sSel & """"
    '  sSearch = "explorer " & Chr(34) & "http://www.baidu.com/baidu?tn=Juncox&word=" & sSel & Chr(34)
      Shell sSearch
   
End Sub
 Sub CommandButton1_Click()


mOpen = Shell("Explorer.exe E:\company\work\", vbNormalFocus)


 


End Sub





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值