【问题标题】:Concatenate hyperlink in Powerpoint VBA在 Powerpoint VBA 中连接超链接
【发布时间】:2015-05-21 01:16:47
【问题描述】:

我正在尝试将 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

提前致谢

【问题讨论】:

    标签: vba powerpoint powerpoint-2013


    【解决方案1】:

    这应该让你更接近一点:

    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
    

    【讨论】:

      【解决方案2】:

      & 总是在字符串上下文中计算,而如果操作数之一不是字符串,+ 可能不会连接:

      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
      

      【讨论】:

      • 为什么我在 Dim projId AS Integer = 617NewWindow:=True, AddHistory:=True 上收到错误
      【解决方案3】:

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

      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
      

      【讨论】:

        猜你喜欢
        • 2014-10-21
        • 2013-08-30
        • 2019-09-07
        • 2015-07-23
        • 1970-01-01
        • 2010-09-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多