0

I am trying to concatenate a URL with many different parts(variables) added to the end of the URL.

I have a button and when you click the button it will takes you to the a specific site using the slide index of the current slide.

When the button is click I want it to go to "google.com/p" + Slide.Index + slide.ID + ActivePresentation.fileName

I know the syntax aren't correct but hopefully you get the GIST.

Currently I have this code:

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

Thanks in advance

3 Answers 3

2

This should get you a bit closer:

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
Sign up to request clarification or add additional context in comments.

Comments

1

& is always evaluated in a string context, while + may not concatenate if one of the operands is no string:

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

1 Comment

Why am I getting an error on Dim projId AS Integer = 617 and NewWindow:=True, AddHistory:=True
0

I have fixed the issue, view the code below!

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.