ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 Excel Home精品图文教程库
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
300集Office 2010微视频教程 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1825|回复: 11

[求助] 鼠标悬停显示

[复制链接]

TA的精华主题

TA的得分主题

发表于 2020-11-16 17:28 | 显示全部楼层 |阅读模式
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
各位大侠,请教一下,WORD中是否可以实现EXCEl 中"数据验证“功能中的”输入信息“功能?即可以提前写好备注,当鼠标悬停在此位置时可以显示出备注信息来?

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-11-17 08:50 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
WORD的这个版块好像人气不足啊
我的这个问题是不是在WORD中不可实现,有没有大神答疑一下

TA的精华主题

TA的得分主题

发表于 2020-11-17 14:33 | 显示全部楼层
楼主:你要的功能完全可以实现。
我找到了一些思路,即对选中的文本添加备注信息,当鼠标悬停在此文本时就弹出备注信息。
代码如下:
  1. Option Explicit

  2. '=========================
  3. 'Macros created 2011 by Lene Fredborg, DocTools - www.thedoctools.com
  4. 'THE MACROS ARE COPYRIGHT. YOU ARE WELCOME TO USE THE MACROS BUT YOU MUST KEEP THE LINE ABOVE.
  5. 'YOU ARE NOT ALLOWED TO PUBLISH THE MACROS AS YOUR OWN, IN WHOLE OR IN PART.
  6. '=========================
  7. 'See the comments in the individual macros
  8. '=========================

  9. 'Constants used by the procedures below - you may change the values
  10. 'Used when naming bookmarks:
  11. Public Const cstrBKStart = "_ScreenTip_"

  12. 'Used for messages:
  13. Public Msg As String
  14. Public Title As String
  15. Public Style As VbMsgBoxStyle
  16. Public Response As VbMsgBoxResult

  17. Sub AddScreenTipToText()

  18.     'Created 2011 by Lene Fredborg, DocTools - www.thedoctools.com
  19.    
  20.     'The macro converts selected text to a hyperlink that shows
  21.     'the screen tip text you specify when a user hovers the mouse over the text.
  22.     'In order to make it easy for the user to identify text with screen tips,
  23.     'a shading color is applied to the text.
  24.     'For further details, see the comments below.

  25.     Dim oRange As Range
  26.     Dim strBK As String
  27.     Dim oHL As Hyperlink
  28.     Dim strScreeenTip As String
  29.     Dim oColor As WdColor
  30.     Dim strScreenTip As String
  31.     Dim strLineSeparator As String
  32.    
  33.     Title = "Add Screen Tip to Selection (Max. 255 Characters)"
  34.    
  35.     'The color specified below will be applied to the selected text
  36.     'You can change the color if you wish
  37.     oColor = wdColorLightTurquoise
  38.    
  39.     'The string specified below can be used to specify a line break
  40.     'in the screen tip text
  41.     'If you need the specified character to be included in the screen tip text as such,
  42.     'change the character to something that will not be used in the screen tip texts
  43.     strLineSeparator = "#"
  44.    
  45.     'Stop if no text is selected
  46.     If Selection.Type = wdSelectionIP Then
  47.         Msg = "Please select the text to which you want to apply a screen tip. Then select this command again."
  48.         MsgBox Msg, vbOKOnly, Title
  49.         Exit Sub
  50.     End If
  51.    
  52.     'Stop if a hyperlink is in the selection
  53.     If Selection.Hyperlinks.Count > 0 Then
  54.         Msg = "The selection already contains hyperlink(s). No changes will be made."
  55.         MsgBox Msg, vbOKOnly, Title
  56.         Exit Sub
  57.     End If
  58.    
  59.     'Let user specify screen tip text
  60. Retry:
  61.     Msg = "This command lets you change the selection so that a screen tip appears if a user hovers the mouse over the text." & vbCr & vbCr & _
  62.             "The command converts the selected text to a hyperlink. In order to make the selection remain unchanged if a user " & _
  63.             "clicks the hyperlink, a bookmark will be added around the hyperlink itself and the " & _
  64.             "hyperlink will be defined to go to that bookmark is the user clicks it. Shading will be applied to the hyperlinked text. " & _
  65.             "in order to make it easy for the user to identify text with screen tips." & vbCr & vbCr & _
  66.             "Please enter the screen tip text you want to appear when the user hovers the mouse over the selected text " & _
  67.             "(to indicate a line break, type " & strLineSeparator & "):"
  68.         
  69.     strScreenTip = InputBox(Msg, Title)

  70.     If Len(strScreenTip) = 0 Then
  71.         If StrPtr(strScreenTip) = 0 Then
  72.             'Cancel clicked
  73.             Exit Sub
  74.         Else
  75.             'OK clicked, empty field
  76.             Msg = "You must enter the desired sceen tip text. Please retry."
  77.             Style = vbOKOnly + vbInformation
  78.             Response = MsgBox(Msg, Style, Title)
  79.             GoTo Retry
  80.         End If
  81.     Else
  82.         'Input accepted
  83.         'Replace any strLineSeparator in the screen tip with vbCr
  84.         strScreenTip = Replace(strScreenTip, strLineSeparator, vbCr)
  85.         
  86.         Set oRange = Selection.Range
  87.         
  88.         'Add bookmark around oRange
  89.         strBK = GetBookmarkName
  90.         oRange.Bookmarks.Add Name:=strBK
  91.         
  92.         'Convert selection to hyperlink
  93.         Set oHL = oRange.Hyperlinks.Add(Anchor:=oRange, Address:="", SubAddress:=strBK)
  94.         With oHL
  95.             .ScreenTip = strScreenTip
  96.             With .Range
  97.                 'Reset font to remove the hyperlink style (default: blue and underlined)
  98.                 'If your document is not formatted with proper styles,
  99.                 'you may need to change the following code
  100.                 .Font.Reset
  101.                 .Shading.BackgroundPatternColor = oColor
  102.                 'Make sure the shading stops after the range
  103.                 .Start = .End
  104.                 .Font.Reset
  105.             End With
  106.         End With
  107.     End If
  108.    
  109.     'Make sure screen tips are shown
  110.     Application.DisplayScreenTips = True
  111.    
  112.     'Clean up
  113.     Set oRange = Nothing
  114.     Set oHL = Nothing

  115. End Sub

  116. Function GetBookmarkName() As String
  117.    
  118.     'Created 2011 by Lene Fredborg, DocTools - www.thedoctools.com
  119.    
  120.     'Function used by the AddScreenTipToText macro.
  121.     'Creates a unique bookmark name in the format "_ScreenTip_X"
  122.    
  123.     Dim n As Long
  124.    
  125.     n = 1
  126.    
  127.     Do Until ActiveDocument.Bookmarks.Exists(cstrBKStart & n) = False
  128.         n = n + 1
  129.     Loop
  130.    
  131.     GetBookmarkName = cstrBKStart & n
  132. End Function

  133. Sub RemoveScreenTipFromText()
  134.     'Removes hyperlink added to text using the AddScreenTipToText macro
  135.     'The cursor must be in the hyperlink or the selection must include the hyperlink
  136.    
  137.     Title = "Remove Screen Tip From Selection"
  138.    
  139.     'Stop if not precisely 1 hyperlink is in the selection
  140.     If Selection.Hyperlinks.Count <> 1 Then
  141.         Msg = "You must first click in or select a single hyperlink that has been added " & _
  142.             "via the AddScreenTipToText macro. Please retry."
  143.         MsgBox Msg, vbOKOnly, Title
  144.         Exit Sub
  145.     End If
  146.    
  147.     With Selection.Hyperlinks(1)
  148.         If InStr(1, .SubAddress, cstrBKStart) > 0 Then
  149.             'Remove background color
  150.             .Range.Shading.BackgroundPatternColor = wdColorAutomatic
  151.             'Remove hyperlink, i.e. convert to normal text
  152.             .Delete
  153.         End If
  154.     End With
  155.    
  156. End Sub

复制代码

评分

1

查看全部评分

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-11-18 08:37 | 显示全部楼层
666611430 发表于 2020-11-17 14:33
楼主:你要的功能完全可以实现。
我找到了一些思路,即对选中的文本添加备注信息,当鼠标悬停在此文本时就 ...

需要用VBA来实现吗?

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-11-18 08:38 | 显示全部楼层
666611430 发表于 2020-11-17 14:33
楼主:你要的功能完全可以实现。
我找到了一些思路,即对选中的文本添加备注信息,当鼠标悬停在此文本时就 ...

对VBA只是了解,还没有能力去编写代码

TA的精华主题

TA的得分主题

发表于 2020-11-18 10:06 | 显示全部楼层
楼主,把上面的代码添加到vba编辑器里模块当中,返回word页面,点击Alt+F8执行代码,之后会弹出一个填写《备注》窗口,填写完备注之后,点击确定就即可。前提你首先选中一段文本。
---------------------------------------------------
不想使用vba,那就试一试如下步骤(添加书签,超链接的方式实现,上面的代码也是采用这个思路)
步骤: 1.png
2.png
3.png
4.png
5.png
6.png

评分

1

查看全部评分

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-11-19 14:20 | 显示全部楼层
666611430 发表于 2020-11-18 10:06
楼主,把上面的代码添加到vba编辑器里模块当中,返回word页面,点击Alt+F8执行代码,之后会弹出一个填写《 ...

感谢感谢,给了一个解决思路了

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-11-19 16:35 | 显示全部楼层
666611430 发表于 2020-11-18 10:06
楼主,把上面的代码添加到vba编辑器里模块当中,返回word页面,点击Alt+F8执行代码,之后会弹出一个填写《 ...

再请教一个问题,在WORD中如何实现编辑权限的控制。比如插入一个文本框或是一个控件,这个文本框或控件不能删除,只能修改其中的文本内容

TA的精华主题

TA的得分主题

发表于 2020-11-19 19:35 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
楼主,你这个可以在《审阅》里边的《限制编辑》来进行设置。
如果,零有办法存在,等老师们回答吧。

TA的精华主题

TA的得分主题

 楼主| 发表于 2020-11-20 14:02 | 显示全部楼层
666611430 发表于 2020-11-19 19:35
楼主,你这个可以在《审阅》里边的《限制编辑》来进行设置。
如果,零有办法存在,等老师们回答吧。

限制编辑中的内容只有“修改”这个大项,修改分为删除、增加、变更,而我想实现的功能是可以修改这个内容,但是不能删除这个控件
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

关闭

最新热点上一条 /1 下一条

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-4-23 15:24 , Processed in 0.040291 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表