0

我正在尝试将 URL 与添加到 URL 末尾的许多不同部分(变量)连接起来。

我有一个按钮,当您单击该按钮时,它将使用当前幻灯片的幻灯片索引将您带到特定站点。

单击按钮时,我希望它转到“google.com/p”+ Slide.Index + slide.ID + ActivePresentation.fileName

我知道语法不正确,但希望你能得到 GIST。

目前我有这个代码:

Private Sub CommandButton21_Click()

    Dim projId AS Integer = 617
    Dim URL AS String = "www.google.com"
    Dim coID = "m01"
    Dim coTitle AS String = "New CC Project"
    Dim oSl As Slide
    Dim pgId



    ActivePresentation.FollowHyperlink _
    Address:="http://google.com/p" + oSl.SlideID
    NewWindow:=True, AddHistory:=True


End Sub

提前致谢

4

3 回答 3

2

这应该让你更接近一点:

Private Sub CommandButton21_Click()
    ' You can't assign values to variables at the same time
    ' as you DIM them; you CAN do so with Constants:
    Const projId As Integer = 617
    Const URL As String = "www.google.com"
    Const coID As String = "m01"
    Const coTitle As String = "New CC Project"
    Dim oSl As Slide
    'Dim pgId

    ' You can't just refer to oSl; you have to first tell it WHICH slide
    Set oSl = ActivePresentation.Slides(1) ' or whatever slide you want

    ActivePresentation.FollowHyperlink _
    Address:="http://google.com/p" & oSl.SlideID, _
    NewWindow:=True, _
    AddHistory:=True

End Sub
于 2015-05-20T14:20:00.797 回答
1

&始终在字符串上下文中进行评估,而+如果操作数之一不是字符串,则可能不会连接:

Private Sub CommandButton21_Click()

    Dim projId AS Integer
    Dim URL AS String = "www.google.com"
    Dim coID = "m01"
    Dim coTitle AS String = "New CC Project"
    Dim oSl As Slide
    Dim pgId
    projId = 617


    ActivePresentation.FollowHyperlink _
    Address="http://google.com/p" & oSl.SlideID
    NewWindow=True
    AddHistory=True


End Sub
于 2015-05-19T20:19:52.107 回答
0

我已经解决了这个问题,查看下面的代码!

Sub CommandButton21_Click()
    Dim sl As slide
    Dim projId As Integer
    Dim coID As String
    Dim URL As String
    Dim coTitle As String
    Dim pgId
    URL = "www.google.com"
    projId = 617
    coID = "m01"
    coTitle = "New CC Project"

    Set sl = SlideShowWindows(1).View.slide

    ActivePresentation.FollowHyperlink _
    Address:=URL & projId & "&coIdent=" & coID & "&coTitle=" & coTitle & "&pgIdent=" & sl.slideId & "&pgTitle=" & sl.slideId & "&pageFileName=" & ActivePresentation.FullName & "&pageOrder=" & sl.SlideIndex, _
    NewWindow:=True, AddHistory:=True
于 2015-05-20T17:16:47.703 回答