简体   繁体   English

通过VBA从Powerpoint打开特定的Excel工作表

[英]Open Particular Excel Worksheet from Powerpoint via VBA

I have a Power Point presentation that contains data pasted into it from Excel using VBA. 我有一个Power Point演示文稿,其中包含使用VBA从Excel粘贴到其中的数据。 The data in the excel file is a table that contains hyperlinks to other worksheets within the same workbook. excel文件中的数据是一个表,其中包含指向同一工作簿中其他工作表的超链接。 The VBA that creates this as an example is : 作为示例创建的VBA是:

'Adds hyperlink to each worksheet user can use to find from powerpoint '将超链接添加到用户可用于从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. 这段代码工作得很好-宏然后将此表粘贴到Powerpoint中。 My problem is the file it is looking for via the powerpoint file is wrong, it is looking for a file called 我的问题是通过powerpoint文件查找的文件是错误的,正在查找名为

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. “标题丢失”是工作表的名称,并且该路径是通过VBA生成的路径,尽管在单击VBA创建的链接时从一个工作表跳到另一个工作表时,该路径可以从Excel内部正常工作。

How do I get the link to the right worksheet to work from within PowerPoint? 如何从PowerPoint中获得指向正确工作表的链接以进行工作?

Use the Address parameter: 使用地址参数:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM