在powerpoint中选定区域插入超链接



我一直在尝试通过单击加载项任务窗格中的按钮在Microsoft Powerpoint幻灯片中插入超链接。

我已经尝试使用setSelectedDataAsync(data, options, callback).但是我只能通过这种方法插入纯文本和图像。

Office.context.document.setSelectedDataAsync('Hello World!',function (asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) 
{
console.log(asyncResult.error.message);
}
});

是否有办法在选定区域插入超链接或HTML ?

不幸的是,这不是你需要的答案(office-js),但对于任何想在VBA中实现它的人:

Sub SetLinkOnActiveShape(strLink As String)
'Inserts a hyperlink on the selected shape(s)
Dim shp As Shape
'Determine if shape(s) is/are selected
If ActiveWindow.Selection.Type = ppSelectionShapes Then
'Loop for each shape in selection
For Each shp In ActiveWindow.Selection.ShapeRange
'Insert link on the shape
With shp.ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = strLink
End With
Next shp
Else
MsgBox "There is no shape currently selected!", vbExclamation, "No Shape Found"
Exit Sub
End If

End Sub

Sub testSetLink()
SetLinkOnActiveShape "https://stackoverflow.com/questions/74569639/inserting-hyperlinks-into-selected-area-in-powerpoint"
End Sub

(https://www.thespreadsheetguru.com/vba/2015/2/18/determine-the-current-activeshape-in-powerpoint-with-vba和https://learn.microsoft.com/en-us/office/vba/api/powerpoint.hyperlink的组合)

最新更新