Open Particular Excel Worksheet from Powerpoint via VBA

谁都会走 提交于 2020-01-25 16:41:31

问题


I have a Power Point presentation that contains data pasted into it from Excel using VBA. The data in the excel file is a table that contains hyperlinks to other worksheets within the same workbook. The VBA that creates this as an example is :

'Adds hyperlink to each worksheet user can use to find from powerpoint

Range("B2").Select

ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
    "'Title Missing'!A1", TextToDisplay:="Missing Title Tags"

This code works just fine - The Macro then pastes this table into Powerpoint. My problem is the file it is looking for via the powerpoint file is wrong, it is looking for a file called

C:\Users\Colin\Desktop\Title Missing.xlsx`

. "Title Missing" is the name of the worksheet and this path is the one being generated via the VBA despite the path working correctly from inside Excel when hopping from one worksheet to the other when clicking on the links the VBA creates.

How do I get the link to the right worksheet to work from within PowerPoint?


回答1:


Use the Address parameter:

ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
   Address:=ActiveSheet.Parent.FullName, _
   SubAddress:="'Title Missing'!A1", TextToDisplay:="Missing Title Tags"


来源:https://stackoverflow.com/questions/41941155/open-particular-excel-worksheet-from-powerpoint-via-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!