+ Reply to Thread
Results 1 to 9 of 9

Help with creating hyperlink via VBA

  1. #1
    FrigidDigit
    Guest

    Help with creating hyperlink via VBA

    Hi All,

    I'm trying to create a hyperlink for each entry in a list of filenames.
    Below is the code that I have come up with so far (I know very little about
    VBA)
    fname = objFolder.Path & "\" & objFile.Name
    Addrs = Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    Listing").Cells(eRow, 8).Address
    MyFormula = "=Hyperlink(" & fname & ")"
    Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    Listing").Range(Addrs).Value = MyFormula

    When I try to run this it gives me a runtime error 1004 Application defined
    or object defined error on the last line above.

    Any help would be much appreciated.

    FD



  2. #2
    Dave Peterson
    Guest

    Re: Help with creating hyperlink via VBA

    Shouldn't this:

    MyFormula = "=Hyperlink(" & fname & ")"
    look more like:

    MyFormula = "=Hyperlink(""" & fname & """)"
    or
    MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"



    FrigidDigit wrote:
    >
    > Hi All,
    >
    > I'm trying to create a hyperlink for each entry in a list of filenames.
    > Below is the code that I have come up with so far (I know very little about
    > VBA)
    > fname = objFolder.Path & "\" & objFile.Name
    > Addrs = Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    > Listing").Cells(eRow, 8).Address
    > MyFormula = "=Hyperlink(" & fname & ")"
    > Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    > Listing").Range(Addrs).Value = MyFormula
    >
    > When I try to run this it gives me a runtime error 1004 Application defined
    > or object defined error on the last line above.
    >
    > Any help would be much appreciated.
    >
    > FD


    --

    Dave Peterson

  3. #3
    FrigidDigit
    Guest

    Re: Help with creating hyperlink via VBA

    Dave,

    what do the """" do?

    FD


    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Shouldn't this:
    >
    > MyFormula = "=Hyperlink(" & fname & ")"
    > look more like:
    >
    > MyFormula = "=Hyperlink(""" & fname & """)"
    > or
    > MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    >
    >
    >
    > FrigidDigit wrote:
    >>
    >> Hi All,
    >>
    >> I'm trying to create a hyperlink for each entry in a list of filenames.
    >> Below is the code that I have come up with so far (I know very little
    >> about
    >> VBA)
    >> fname = objFolder.Path & "\" & objFile.Name
    >> Addrs = Workbooks("Subcontractor invoices
    >> Overview.xls").Worksheets("Invoice
    >> Listing").Cells(eRow, 8).Address
    >> MyFormula = "=Hyperlink(" & fname & ")"
    >> Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    >> Listing").Range(Addrs).Value = MyFormula
    >>
    >> When I try to run this it gives me a runtime error 1004 Application
    >> defined
    >> or object defined error on the last line above.
    >>
    >> Any help would be much appreciated.
    >>
    >> FD

    >
    > --
    >
    > Dave Peterson




  4. #4
    FrigidDigit
    Guest

    Re: Help with creating hyperlink via VBA

    Dave you are a genius!!
    Thank you so much!!


    "FrigidDigit" <[email protected]> wrote in message
    news:[email protected]...
    > Dave,
    >
    > what do the """" do?
    >
    > FD
    >
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    >> Shouldn't this:
    >>
    >> MyFormula = "=Hyperlink(" & fname & ")"
    >> look more like:
    >>
    >> MyFormula = "=Hyperlink(""" & fname & """)"
    >> or
    >> MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    >>
    >>
    >>
    >> FrigidDigit wrote:
    >>>
    >>> Hi All,
    >>>
    >>> I'm trying to create a hyperlink for each entry in a list of filenames.
    >>> Below is the code that I have come up with so far (I know very little
    >>> about
    >>> VBA)
    >>> fname = objFolder.Path & "\" & objFile.Name
    >>> Addrs = Workbooks("Subcontractor invoices
    >>> Overview.xls").Worksheets("Invoice
    >>> Listing").Cells(eRow, 8).Address
    >>> MyFormula = "=Hyperlink(" & fname & ")"
    >>> Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    >>> Listing").Range(Addrs).Value = MyFormula
    >>>
    >>> When I try to run this it gives me a runtime error 1004 Application
    >>> defined
    >>> or object defined error on the last line above.
    >>>
    >>> Any help would be much appreciated.
    >>>
    >>> FD

    >>
    >> --
    >>
    >> Dave Peterson

    >
    >




  5. #5
    Dave Peterson
    Guest

    Re: Help with creating hyperlink via VBA

    I take it that it worked!!

    Glad you got it going.

    FrigidDigit wrote:
    >
    > Dave you are a genius!!
    > Thank you so much!!
    >
    > "FrigidDigit" <[email protected]> wrote in message
    > news:[email protected]...
    > > Dave,
    > >
    > > what do the """" do?
    > >
    > > FD
    > >
    > >
    > > "Dave Peterson" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> Shouldn't this:
    > >>
    > >> MyFormula = "=Hyperlink(" & fname & ")"
    > >> look more like:
    > >>
    > >> MyFormula = "=Hyperlink(""" & fname & """)"
    > >> or
    > >> MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    > >>
    > >>
    > >>
    > >> FrigidDigit wrote:
    > >>>
    > >>> Hi All,

    > ???
    > ??? I'm trying to create a hyperlink for each entry in a list of filenames.
    > ??? Below is the code that I have come up with so far (I know very little
    > ??? about
    > ??? VBA)
    > ??? fname = objFolder.Path ? "\" ? objFile.Name
    > ??? Addrs = Workbooks("Subcontractor invoices
    > ??? Overview.xls").Worksheets("Invoice
    > ??? Listing").Cells(eRow, 8).Address
    > ??? MyFormula = "=Hyperlink(" ? fname ? ")"
    > ??? Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    > ??? Listing").Range(Addrs).Value = MyFormula
    > ???
    > ??? When I try to run this it gives me a runtime error 1004 Application
    > ??? defined
    > ??? or object defined error on the last line above.
    > ???
    > ??? Any help would be much appreciated.
    > ???
    > ??? FD
    > ??
    > ?? --
    > ??
    > ?? Dave Peterson
    > ?
    > ?


    --

    Dave Peterson

  6. #6
    FrigidDigit
    Guest

    Re: Help with creating hyperlink via VBA

    Worked like a bomb!

    Could you explain to me wht """ was used?

    Thanks again.

    FD


    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    >I take it that it worked!!
    >
    > Glad you got it going.
    >
    > FrigidDigit wrote:
    >>
    >> Dave you are a genius!!
    >> Thank you so much!!
    >>
    >> "FrigidDigit" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > Dave,
    >> >
    >> > what do the """" do?
    >> >
    >> > FD
    >> >
    >> >
    >> > "Dave Peterson" <[email protected]> wrote in message
    >> > news:[email protected]...
    >> >> Shouldn't this:
    >> >>
    >> >> MyFormula = "=Hyperlink(" & fname & ")"
    >> >> look more like:
    >> >>
    >> >> MyFormula = "=Hyperlink(""" & fname & """)"
    >> >> or
    >> >> MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    >> >>
    >> >>
    >> >>
    >> >> FrigidDigit wrote:
    >> >>>
    >> >>> Hi All,

    >> ???
    >> ??? I'm trying to create a hyperlink for each entry in a list of
    >> filenames.
    >> ??? Below is the code that I have come up with so far (I know very little
    >> ??? about
    >> ??? VBA)
    >> ??? fname = objFolder.Path ? "\" ? objFile.Name
    >> ??? Addrs = Workbooks("Subcontractor invoices
    >> ??? Overview.xls").Worksheets("Invoice
    >> ??? Listing").Cells(eRow, 8).Address
    >> ??? MyFormula = "=Hyperlink(" ? fname ? ")"
    >> ??? Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    >> ??? Listing").Range(Addrs).Value = MyFormula
    >> ???
    >> ??? When I try to run this it gives me a runtime error 1004 Application
    >> ??? defined
    >> ??? or object defined error on the last line above.
    >> ???
    >> ??? Any help would be much appreciated.
    >> ???
    >> ??? FD
    >> ??
    >> ?? --
    >> ??
    >> ?? Dave Peterson
    >> ?
    >> ?

    >
    > --
    >
    > Dave Peterson




  7. #7
    Tom Ogilvy
    Guest

    Re: Help with creating hyperlink via VBA

    It puts in a double quote within a string.

    You can see this by examining it from the immediate window:

    fname = "Goofy"
    ? "=Hyperlink(""" & fname & """)"
    =Hyperlink("Goofy")


    --
    Regards,
    Tom Ogilvy

    "FrigidDigit" <[email protected]> wrote in message
    news:[email protected]...
    > Worked like a bomb!
    >
    > Could you explain to me wht """ was used?
    >
    > Thanks again.
    >
    > FD
    >
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > >I take it that it worked!!
    > >
    > > Glad you got it going.
    > >
    > > FrigidDigit wrote:
    > >>
    > >> Dave you are a genius!!
    > >> Thank you so much!!
    > >>
    > >> "FrigidDigit" <[email protected]> wrote in message
    > >> news:[email protected]...
    > >> > Dave,
    > >> >
    > >> > what do the """" do?
    > >> >
    > >> > FD
    > >> >
    > >> >
    > >> > "Dave Peterson" <[email protected]> wrote in message
    > >> > news:[email protected]...
    > >> >> Shouldn't this:
    > >> >>
    > >> >> MyFormula = "=Hyperlink(" & fname & ")"
    > >> >> look more like:
    > >> >>
    > >> >> MyFormula = "=Hyperlink(""" & fname & """)"
    > >> >> or
    > >> >> MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    > >> >>
    > >> >>
    > >> >>
    > >> >> FrigidDigit wrote:
    > >> >>>
    > >> >>> Hi All,
    > >> ???
    > >> ??? I'm trying to create a hyperlink for each entry in a list of
    > >> filenames.
    > >> ??? Below is the code that I have come up with so far (I know very

    little
    > >> ??? about
    > >> ??? VBA)
    > >> ??? fname = objFolder.Path ? "\" ? objFile.Name
    > >> ??? Addrs = Workbooks("Subcontractor invoices
    > >> ??? Overview.xls").Worksheets("Invoice
    > >> ??? Listing").Cells(eRow, 8).Address
    > >> ??? MyFormula = "=Hyperlink(" ? fname ? ")"
    > >> ??? Workbooks("Subcontractor invoices

    Overview.xls").Worksheets("Invoice
    > >> ??? Listing").Range(Addrs).Value = MyFormula
    > >> ???
    > >> ??? When I try to run this it gives me a runtime error 1004 Application
    > >> ??? defined
    > >> ??? or object defined error on the last line above.
    > >> ???
    > >> ??? Any help would be much appreciated.
    > >> ???
    > >> ??? FD
    > >> ??
    > >> ?? --
    > >> ??
    > >> ?? Dave Peterson
    > >> ?
    > >> ?

    > >
    > > --
    > >
    > > Dave Peterson

    >
    >




  8. #8
    FrigidDigit
    Guest

    Re: Help with creating hyperlink via VBA

    Thanks Tom

    FD

    "Tom Ogilvy" <[email protected]> wrote in message
    news:%[email protected]...
    > It puts in a double quote within a string.
    >
    > You can see this by examining it from the immediate window:
    >
    > fname = "Goofy"
    > ? "=Hyperlink(""" & fname & """)"
    > =Hyperlink("Goofy")
    >
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "FrigidDigit" <[email protected]> wrote in message
    > news:[email protected]...
    >> Worked like a bomb!
    >>
    >> Could you explain to me wht """ was used?
    >>
    >> Thanks again.
    >>
    >> FD
    >>
    >>
    >> "Dave Peterson" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >I take it that it worked!!
    >> >
    >> > Glad you got it going.
    >> >
    >> > FrigidDigit wrote:
    >> >>
    >> >> Dave you are a genius!!
    >> >> Thank you so much!!
    >> >>
    >> >> "FrigidDigit" <[email protected]> wrote in message
    >> >> news:[email protected]...
    >> >> > Dave,
    >> >> >
    >> >> > what do the """" do?
    >> >> >
    >> >> > FD
    >> >> >
    >> >> >
    >> >> > "Dave Peterson" <[email protected]> wrote in message
    >> >> > news:[email protected]...
    >> >> >> Shouldn't this:
    >> >> >>
    >> >> >> MyFormula = "=Hyperlink(" & fname & ")"
    >> >> >> look more like:
    >> >> >>
    >> >> >> MyFormula = "=Hyperlink(""" & fname & """)"
    >> >> >> or
    >> >> >> MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >> FrigidDigit wrote:
    >> >> >>>
    >> >> >>> Hi All,
    >> >> ???
    >> >> ??? I'm trying to create a hyperlink for each entry in a list of
    >> >> filenames.
    >> >> ??? Below is the code that I have come up with so far (I know very

    > little
    >> >> ??? about
    >> >> ??? VBA)
    >> >> ??? fname = objFolder.Path ? "\" ? objFile.Name
    >> >> ??? Addrs = Workbooks("Subcontractor invoices
    >> >> ??? Overview.xls").Worksheets("Invoice
    >> >> ??? Listing").Cells(eRow, 8).Address
    >> >> ??? MyFormula = "=Hyperlink(" ? fname ? ")"
    >> >> ??? Workbooks("Subcontractor invoices

    > Overview.xls").Worksheets("Invoice
    >> >> ??? Listing").Range(Addrs).Value = MyFormula
    >> >> ???
    >> >> ??? When I try to run this it gives me a runtime error 1004
    >> >> Application
    >> >> ??? defined
    >> >> ??? or object defined error on the last line above.
    >> >> ???
    >> >> ??? Any help would be much appreciated.
    >> >> ???
    >> >> ??? FD
    >> >> ??
    >> >> ?? --
    >> >> ??
    >> >> ?? Dave Peterson
    >> >> ?
    >> >> ?
    >> >
    >> > --
    >> >
    >> > Dave Peterson

    >>
    >>

    >
    >




  9. #9
    Dave Peterson
    Guest

    Re: Help with creating hyperlink via VBA

    Sorry, I thought you saw the quote marks when you looked at the formula in the
    cell.

    FrigidDigit wrote:
    >
    > Worked like a bomb!
    >
    > Could you explain to me wht """ was used?
    >
    > Thanks again.
    >
    > FD
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > >I take it that it worked!!
    > >
    > > Glad you got it going.
    > >
    > > FrigidDigit wrote:
    > >>
    > >> Dave you are a genius!!
    > >> Thank you so much!!
    > >>
    > >> "FrigidDigit" <[email protected]> wrote in message
    > >> news:[email protected]...
    > >> > Dave,
    > >> >
    > >> > what do the """" do?
    > >> >
    > >> > FD
    > >> >
    > >> >
    > >> > "Dave Peterson" <[email protected]> wrote in message
    > >> > news:[email protected]...
    > >> >> Shouldn't this:
    > >> >>
    > >> >> MyFormula = "=Hyperlink(" & fname & ")"
    > >> >> look more like:
    > >> >>
    > >> >> MyFormula = "=Hyperlink(""" & fname & """)"
    > >> >> or
    > >> >> MyFormula = "=Hyperlink(" & chr(34) & fname & Chr(34) & ")"
    > >> >>
    > >> >>
    > >> >>
    > >> >> FrigidDigit wrote:
    > >> >>>
    > >> >>> Hi All,
    > >> ???
    > >> ??? I'm trying to create a hyperlink for each entry in a list of
    > >> filenames.
    > >> ??? Below is the code that I have come up with so far (I know very little
    > >> ??? about
    > >> ??? VBA)
    > >> ??? fname = objFolder.Path ? "\" ? objFile.Name
    > >> ??? Addrs = Workbooks("Subcontractor invoices
    > >> ??? Overview.xls").Worksheets("Invoice
    > >> ??? Listing").Cells(eRow, 8).Address
    > >> ??? MyFormula = "=Hyperlink(" ? fname ? ")"
    > >> ??? Workbooks("Subcontractor invoices Overview.xls").Worksheets("Invoice
    > >> ??? Listing").Range(Addrs).Value = MyFormula
    > >> ???
    > >> ??? When I try to run this it gives me a runtime error 1004 Application
    > >> ??? defined
    > >> ??? or object defined error on the last line above.
    > >> ???
    > >> ??? Any help would be much appreciated.
    > >> ???
    > >> ??? FD
    > >> ??
    > >> ?? --
    > >> ??
    > >> ?? Dave Peterson
    > >> ?
    > >> ?

    > >
    > > --
    > >
    > > Dave Peterson


    --

    Dave Peterson

+ 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.6.0 RC 1