+ Reply to Thread
Results 1 to 8 of 8

Thread: Adding quotes around a variable url?

  1. #1
    Registered User
    Join Date
    10-20-2010
    Location
    Indiana, US
    MS-Off Ver
    Excel 2004
    Posts
    7

    Adding quotes around a variable url?

    I have a macro that takes pertinent info from our customer's orders. PO number, order date, etc. This info will then be pasted into a new document (along with other orders of the day) for upload into our online database. We also want to automatically generate a link for the client to view a PDF of their order. To import a link into the database, it must contain html tags. The macro copies the PO number (123456) and pastes it into the link cell. Then the macro appends this to the front of the number:

    <a href="http://www.ourwebaddress/

    And appends this to the end:

    .pdf">thumbnail</a>

    So, ideally, we end up with:

    <a href="http://www.ourwebaddress/123456.pdf">thumbnail</a>

    The problem are the quotes. Particularly since we are adding the opening and closing quotes separately because the actual PO number is a variable. The quotes create errors.

    I have also tried adding the tags minus the quotes and then using the replace function to replace http with "http and pdf with pdf". No luck there either. I'm fairly new to this and I'm sure there is probably an easy fix. Any help will be greatly appreciated.
    Last edited by Zarkov; 10-20-2010 at 04:16 PM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: Adding quotes around a variable url?

    With no code of yours to look at, this is just to show you the syntax for including quotes in a string:
    Dim POnum As String:    POnum = Range("A1")
    Dim Pref As String:     Pref = "<a href=""http://www.ourwebaddress/"
    Dim Suff As String:     Suff = ".pdf"">thumbnail</a>"
    
    Range("B1") = Pref & POnum & Suff
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Adding quotes around a variable url?

    @zarkov, if you opt to post the same question of multiple message boards please have the courtesy to disclose all relevant links

    http://www.mrexcel.com/forum/showthread.php?t=503109

  4. #4
    Registered User
    Join Date
    10-20-2010
    Location
    Indiana, US
    MS-Off Ver
    Excel 2004
    Posts
    7

    Re: Adding quotes around a variable url?

    Thank you. That did it. I was putting in too many extra quotes trying to over-enclose the url.

    I knew it was a simple fix.

  5. #5
    Registered User
    Join Date
    10-20-2010
    Location
    Indiana, US
    MS-Off Ver
    Excel 2004
    Posts
    7

    Re: Adding quotes around a variable url?

    Sorry, didn't realize I was being discourteous. Just had a question, found two high profile forums and posted.

  6. #6
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Adding quotes around a variable url?

    It's simply the fact that whilst others may trying to resolve your problem at MrExcel they are unaware that the issue has been resolved already here.
    It follows that whatever free time they spent on it could have been better spent aiding someone else.
    Were roles reversed JB would have his time wasted.

    For the most part people don't mind if you cross post they just ask you let them know so they can see if the issue is resolved before working on it.
    That said regular cross posters generally find their posts ignored over time as people become wary of getting involved for reasons stated above.

  7. #7
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: Adding quotes around a variable url?

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  8. #8
    Registered User
    Join Date
    10-20-2010
    Location
    Indiana, US
    MS-Off Ver
    Excel 2004
    Posts
    7

    Re: Adding quotes around a variable url?

    Change made, thanks again.

    And I see your point about time wasting. I'll do that in the future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0