通过VBA从Powerpoint打开特定的Excel工作表 [英] Open Particular Excel Worksheet from Powerpoint via VBA

查看:162
本文介绍了通过VBA从Powerpoint打开特定的Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Power Point演示文稿,其中包含使用VBA从Excel粘贴到其中的数据.excel文件中的数据是一个表,其中包含指向同一工作簿中其他工作表的超链接.以此为例的VBA是:

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 :

'将超链接添加到用户可用于从PowerPoint查找的每个工作表

'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"

此代码工作得很好-宏然后将该表粘贴到Powerpoint中.我的问题是通过powerpoint文件查找的文件是错误的,正在查找名为

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`

.标题丢失"是工作表的名称,并且该路径是通过VBA生成的路径,尽管在单击VBA创建的链接时从一个工作表跳到另一个工作表时,该路径可以从Excel内部正常工作.

. "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.

如何从PowerPoint中获得指向正确工作表的链接?

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

推荐答案

使用Address参数:

Use the Address parameter:

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

这篇关于通过VBA从Powerpoint打开特定的Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆