乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 79|回复: 4

超链接(VBA)问题...

[复制链接]

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-2-8 09:44:13 | 显示全部楼层 |阅读模式
嗨,
有超链接问题....我目前正在做的程序将获取用户文本等,并在模型空间中插入一个预先制作的模型空间标记块,以指示所选布局指向的位置 - 它还应该添加指向所选布局的超链接(到标记块),以便用户可以跳转到该布局。
一切都很好,只是超链接部分,我现在必须工作。检查超链接编辑器后,每当您手动将超链接添加到布局时,要显示的路径,url和文本看起来都像它们应该的那样 - 即使在此绘图页面的目标或视图上,它也会突出显示正确的布局,但它不会跳转到布局,而是打开一个Windows资源管理器窗口到绘图路径目录。
如果我打开超链接编辑器,正如我所说,它看起来都很好,并且由于某种原因,如果我单击“确定”,那么这次再次尝试链接是有效的,但前提是我这样做,否则它只会打开资源管理器。
以下是程序代码的摘录。有人可以看看可能出了什么问题,或者让我知道为什么链接不能100%工作。
  1. Option Explicit
  2. Dim response As Integer  'Yes/No..
  3. Dim layoutX, layoutY As AcadLayout  'Acad Layout..
  4. Dim layoutZ As String
  5. Dim blockX As AcadBlockReference 'Inserted block..
  6. Dim blockPoint As Variant ' Pick point for block insert..
  7. Dim attribZ As Variant ' Attributes for inserted block..
  8. Dim countx As Integer 'Counter for getting attributes..
  9. Dim EntX As AcadEntity 'Acad Object (Block search for dblclick listbox)..
  10. Dim Hyp As AcadHyperlink 'Add hyperlink to block..
  11. Dim HypS As AcadHyperlinks 'Hyperlinks collection for block..
  12. '********************************************
  13. '************** INSERT BLOCK ****************
  14. '********************************************
  15. Private Sub insertmarkerBTN_Click()
  16. ' Check if all information is present..
  17. If DetDesc1TXT.Text = "" Then
  18.     MsgBox "Please enter the main Detail title..", vbExclamation, "ModelSpace Detail Marker.."
  19.     Exit Sub
  20. End If
  21. ' Check if all information is present..
  22. If drawnumTXT.Text = "" Then
  23.     MsgBox "Please enter the main Drawing Number (or select it from the list)..", vbExclamation, "ModelSpace Detail Marker.."
  24.     Exit Sub
  25. End If
  26. ModelDetailRefFRM.Hide
  27. ThisDrawing.ActiveSpace = acModelSpace
  28. 'Get pick point..
  29. 'Error Test for GetPoint method..
  30. On Error Resume Next
  31. TryAgainX:
  32. blockPoint = ThisDrawing.Utility.GetPoint(, vbCr & "Pick the insertion point for the Detail Reference Marker.. ")
  33. ErrHndlrX:
  34.     If Err.Number  0 Then
  35.         Err.Clear
  36.         GoTo TryAgainX
  37.     End If
  38.     On Error GoTo ErrHndlrX
  39. 'Insert block..
  40.     Set blockX = ThisDrawing.ModelSpace.InsertBlock(blockPoint, "X:\AbiCAD Blocks\General\Detail Reference - MSpace.dwg", 1#, 1#, 1#, 0)
  41.     blockX.Layer = "X-Notes"
  42. ' Get and edit attributes..
  43. attribZ = blockX.GetAttributes ' Get Block attributes..
  44. ' Loop through attributes..
  45. For countx = LBound(attribZ) To UBound(attribZ)
  46.     Select Case attribZ(countx).TagString
  47.     Case "DRAWING_NUMBER"
  48.         attribZ(countx).TextString = drawnumTXT.Text
  49.     Case "DETAIL_NUMBER"
  50.         attribZ(countx).TextString = detnumTXT.Text
  51.     Case "DETAIL_DESC_1"
  52.         attribZ(countx).TextString = DetDesc1TXT.Text
  53.     Case "DETAIL_DESC_2"
  54.         attribZ(countx).TextString = DetDesc2TXT.Text
  55.     End Select
  56. Next countx
  57. [color=red]' Add the Hyperlink to the block to link back to the Layout..
  58. Set HypS = blockX.Hyperlinks
  59. ' Add a new Hyperlink complete with all properties
  60. Set Hyp = HypS.Add(LayoutLIST.Text)
  61. Hyp.URL = "#," & layoutZ
  62. Hyp.URLNamedLocation = "," & layoutZ[/color]
  63. blockX.Update
  64. ModelDetailRefFRM.Show
  65. End Sub
  66. '********************************************
  67. '************** INSERT BLOCK ****************
  68. '********************************************

有什么想法吗?
干杯,
保罗
基地点设计zltd..
P4 3.0Ghz / 2GB 内存.
XP Pro SP2..
蓝宝石 X1950 512MB 双 DVi 显卡.
AutoCAD 2008..

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2008-2-8 10:32:02 | 显示全部楼层
我没有弄乱超链接,但看起来你可以用xdata做你想做的事情。
然后使用doubleclick事件
1)检查块ref
2)检查xdata
如果是这样做布局thang。
回复

使用道具 举报

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-2-8 10:55:24 | 显示全部楼层
嗨,
太好了,谢谢。这至少清除了一些事情 - 当我回到工作时会测试它。
不过,小问题是什么?布局如何编号?它们是按照您创建的顺序顺序编号的,还是按屏幕底部的 Tab 格式从左到右的顺序编号?我如何正确编码它以找出布局纸质空间视图参考编号?
再次感谢,这为这个主题提供了更多的启示。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2008-2-9 12:24:05 | 显示全部楼层
这是我使用的代码
  1. Private Sub insertmarkerBTN_Click()
  2. Dim blockX As AcadBlockReference 'Inserted block..
  3. Dim blockPoint As Variant ' Pick point for block insert..
  4. Dim HypS As AcadHyperlinks 'Hyperlinks collection for block..
  5. Dim Hyp As AcadHyperlink
  6. ThisDrawing.ActiveSpace = acModelSpace
  7. blockPoint = ThisDrawing.Utility.GetPoint(, vbCr & "Pick the insertion point for the Detail Reference Marker.. ")
  8. Set blockX = ThisDrawing.ModelSpace.InsertBlock(blockPoint, "ScaledFrame", 1#, 1#, 1#, 0)
  9. Set HypS = blockX.Hyperlinks
  10. Set Hyp = HypS.Add(ThisDrawing.Name)
  11. Hyp.URLNamedLocation = "2"
  12. Dim V As AcadView
  13. Dim L As AcadLayout
  14. Dim i As Integer
  15. For Each L In ThisDrawing.Layouts
  16.     If Not UCase(L.Name) = "MODEL" Then
  17.         i = i + 1
  18.         ThisDrawing.ActiveLayout = L
  19.         Set V = ThisDrawing.Views.Add(i)
  20.         V.LayoutId = L.ObjectID
  21.     End If
  22. Next
  23. End Sub

并且图中的超链接将您踢到layout2
Added-看来您必须运行一次代码才能让超链接获得正确的thisdrawing.name
回复

使用道具 举报

46

主题

118

帖子

23

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
291
发表于 2008-2-9 19:12:11 | 显示全部楼层
跳转到布局2的原因
  1. Since the view for "layout2" is called "2" the following code took me directly to the layout2

它对我有效,并且有足够的信息让你推断出代码对你有效。
我认为这种方法不会给你100%的回报,这有点冒险。
xdata方法和右键单击或双击事件可能更好。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-5 08:28 , Processed in 0.805715 second(s), 62 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表