Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Posted yesterday: open linked template not working

Discussion in 'Information Technology' started by dogmelissa, Jul 28, 2006.

  1. dogmelissa

    dogmelissa
    Expand Collapse
    Guest

    Please help. I have excel template files which open to a new file when you
    double-click on them. This is normal. I want to make buttons on my form in
    Access to do the same thing, but when I put in the code that someone
    suggested, it opens the actual template file and not a new file.
    The code is as follows:
    Private Sub NewTakeoff_Click()
    FollowHyperlink "C:\~~~\Corona Material Takeoff Sheet.xlt"
    End Sub

    Please help. I have 3 different files I want to open and I can't get any of
    them to work.
    Thanks,
    Melissa
     
  2. Loading...

    Similar Threads Forum Date
    A Blog Posted by Singapore 's Youngest Millionaire Inspirational Stories Nov 18, 2008
    Sikh News Rangers posted in 26 districts of Punjab (The Pakistan Link) Breaking News Feb 16, 2008
    Doha conference on religions opens today Web posted at: 6/29/2005 2:22:46 (The Peninsula) Interfaith Dialogues Jun 30, 2005
    Misls Sikh Misls - Yesterday, Today & Tomorrow History of Sikhism Jan 6, 2011
    Yesterday's Door ! Spiritual Articles Jan 30, 2006

  3. Wayne-in-Manchester

    Wayne-in-Manchester
    Expand Collapse
    Guest

    You don't really need any code. Simply choose one of your reports or forms
    that you like the look of and save this as the template for new reports or
    forms.

    To change form or report template that you use as a template.

    1st On the main page (the 1st page you get when you open your D Base) click
    "Tools" then "Options"
    2nd In the "Category Box" click "Form & Report Design" and in the "Item Box"
    insert the name of the report or form that you want to use as you template
    for others (insert these names into the "Template" field)

    There is an even simpler way - just save your report or form (the ones you
    want to use a templates) and call them "Normal".

    Hope this helps


    --
    Wayne

    If you feel this answer has been useful please check the "was this post
    helpful" so I get some feedback. Thanks.



    "dogmelissa" wrote:

    > Please help. I have excel template files which open to a new file when you
    > double-click on them. This is normal. I want to make buttons on my form in
    > Access to do the same thing, but when I put in the code that someone
    > suggested, it opens the actual template file and not a new file.
    > The code is as follows:
    > Private Sub NewTakeoff_Click()
    > FollowHyperlink "C:\~~~\Corona Material Takeoff Sheet.xlt"
    > End Sub
    >
    > Please help. I have 3 different files I want to open and I can't get any of
    > them to work.
    > Thanks,
    > Melissa
     
  4. dogmelissa

    dogmelissa
    Expand Collapse
    Guest

    You're not understanding what I want to do.
    I have Excel Templates which I'm trying to use through my Access Database
    Form. I only want them to open to a new template-based file, the same way
    they do if I was to click on the icon for the file, but I want to do it with
    a button on my Access Form page.
    I have code associated with an "on click" command on the buttons, but it's
    opening the .xlt file and not using the template to open a new .xls file. The
    code is as shown in the original post.
    I can get it to open brand-new, blank excel files, but not the templates.

    Help?
    Melissa



    "Wayne-in-Manchester" wrote:

    > You don't really need any code. Simply choose one of your reports or forms
    > that you like the look of and save this as the template for new reports or
    > forms.
    >
    > To change form or report template that you use as a template.
    >
    > 1st On the main page (the 1st page you get when you open your D Base) click
    > "Tools" then "Options"
    > 2nd In the "Category Box" click "Form & Report Design" and in the "Item Box"
    > insert the name of the report or form that you want to use as you template
    > for others (insert these names into the "Template" field)
    >
    > There is an even simpler way - just save your report or form (the ones you
    > want to use a templates) and call them "Normal".
    >
    > Hope this helps
    >
    >
    > --
    > Wayne
    >
    > If you feel this answer has been useful please check the "was this post
    > helpful" so I get some feedback. Thanks.
    >
    >
    >
    > "dogmelissa" wrote:
    >
    > > Please help. I have excel template files which open to a new file when you
    > > double-click on them. This is normal. I want to make buttons on my form in
    > > Access to do the same thing, but when I put in the code that someone
    > > suggested, it opens the actual template file and not a new file.
    > > The code is as follows:
    > > Private Sub NewTakeoff_Click()
    > > FollowHyperlink "C:\~~~\Corona Material Takeoff Sheet.xlt"
    > > End Sub
    > >
    > > Please help. I have 3 different files I want to open and I can't get any of
    > > them to work.
    > > Thanks,
    > > Melissa
     
  5. Wayne-in-Manchester

    Wayne-in-Manchester
    Expand Collapse
    Guest

    Sorry to say I have never coded excel - am sure someone on this site will be
    able to supply you with an answer
     
  6. dogmelissa

    dogmelissa
    Expand Collapse
    Guest

    Not trying to code excel. Trying to code *Access* to open an excel file.

    "Wayne-in-Manchester" wrote:

    > Sorry to say I have never coded excel - am sure someone on this site will be
    > able to supply you with an answer
    >
    >
    >
     
  7. I would try this link it seems they were discussing the same idea your
    trying to do

    http://groups.google.ca/group/micro...+excel+template&rnum=5&hl=en#6c4130d98cbaf48b

    its long and ugly but it may do the trick for you

    I ws playing around with using the Call Shell() Command in VBA but that does
    the same thing you describe above in that it just opens the template.

    Gary Townsend
    Spatial Mapping Ltd.
    "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > Not trying to code excel. Trying to code *Access* to open an excel file.
    >
    > "Wayne-in-Manchester" wrote:
    >
    > > Sorry to say I have never coded excel - am sure someone on this site

    will be
    > > able to supply you with an answer
    > >
    > >
    > >
     
  8. dogmelissa

    dogmelissa
    Expand Collapse
    Guest

    Gary,
    Thanks for trying... I looked at that link and tried the code that worked
    for the other person trying. However, mine is giving me an error on the first
    line.
    Code is as follows:
    Private Sub NewTakeoff_Click()

    Dim ExcelObj As New Excel.Application
    ExcelObj.Workbooks.Add ("C:\~~~\Corona Material Takeoff Sheet.xlt")
    ExcelObj.Visible = True
    ExcelObj.Run ("Auto_Open")
    Set ExcelObj = Nothing

    End Sub

    and the error is highliting the Dim ExcelObj line with the following text:
    "Compile error: User-defined type not defined"
    Any thoughts? Or should I post this to the link you gave me?

    Melissa


    "Gary Townsend (Spatial Mapping Ltd.)" wrote:

    > I would try this link it seems they were discussing the same idea your
    > trying to do
    >
    > http://groups.google.ca/group/micro...+excel+template&rnum=5&hl=en#6c4130d98cbaf48b
    >
    > its long and ugly but it may do the trick for you
    >
    > I ws playing around with using the Call Shell() Command in VBA but that does
    > the same thing you describe above in that it just opens the template.
    >
    > Gary Townsend
    > Spatial Mapping Ltd.
    > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > Not trying to code excel. Trying to code *Access* to open an excel file.
    > >
    > > "Wayne-in-Manchester" wrote:
    > >
    > > > Sorry to say I have never coded excel - am sure someone on this site

    > will be
    > > > able to supply you with an answer
    > > >
    > > >
    > > >

    >
    >
    >
     
  9. This is what i banged off in my spare time seems to work but you have to
    include a reference to Microsoft Excel Object Library in your project
    references. Alt+F11 then Tools>References and scroll till you find the
    library and check the box. Then you can inser this code wherever you want.
    HOwever i am not sure what you need to do with this once you have it open so
    it may or may not work.

    Dim obj As New Excel.Application
    obj.Workbooks.Add ("C:\Pardus.xlt")
    obj.Visible = True

    --
    ===============================
    Gary Townsend
    Database & Application Developer
    Spatial Mapping Ltd.

    "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > Not trying to code excel. Trying to code *Access* to open an excel file.
    >
    > "Wayne-in-Manchester" wrote:
    >
    > > Sorry to say I have never coded excel - am sure someone on this site

    will be
    > > able to supply you with an answer
    > >
    > >
    > >
     
  10. Yeah see my other post in the thread here i realized afterwards they didn't
    talk at all about including references to object libraries.

    --
    ===============================
    Gary Townsend
    Database & Application Developer
    Spatial Mapping Ltd.

    "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    news:1E593EDF-0357-499F-B040-1ECAE886D81E@microsoft.com...
    > Gary,
    > Thanks for trying... I looked at that link and tried the code that worked
    > for the other person trying. However, mine is giving me an error on the

    first
    > line.
    > Code is as follows:
    > Private Sub NewTakeoff_Click()
    >
    > Dim ExcelObj As New Excel.Application
    > ExcelObj.Workbooks.Add ("C:\~~~\Corona Material Takeoff Sheet.xlt")
    > ExcelObj.Visible = True
    > ExcelObj.Run ("Auto_Open")
    > Set ExcelObj = Nothing
    >
    > End Sub
    >
    > and the error is highliting the Dim ExcelObj line with the following text:
    > "Compile error: User-defined type not defined"
    > Any thoughts? Or should I post this to the link you gave me?
    >
    > Melissa
    >
    >
    > "Gary Townsend (Spatial Mapping Ltd.)" wrote:
    >
    > > I would try this link it seems they were discussing the same idea your
    > > trying to do
    > >
    > >

    http://groups.google.ca/group/micro...+excel+template&rnum=5&hl=en#6c4130d98cbaf48b
    > >
    > > its long and ugly but it may do the trick for you
    > >
    > > I ws playing around with using the Call Shell() Command in VBA but that

    does
    > > the same thing you describe above in that it just opens the template.
    > >
    > > Gary Townsend
    > > Spatial Mapping Ltd.
    > > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > > Not trying to code excel. Trying to code *Access* to open an excel

    file.
    > > >
    > > > "Wayne-in-Manchester" wrote:
    > > >
    > > > > Sorry to say I have never coded excel - am sure someone on this site

    > > will be
    > > > > able to supply you with an answer
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
  11. dogmelissa

    dogmelissa
    Expand Collapse
    Guest

    Gary,
    I might be having a blond moment... what do you mean by needing to include
    an excel reference in my project references?
    I also posted a new post to the Google group you linked to (the specific
    topic was from 2003 and no longer accessible for new posts).
    Thanks much for you help!
    Melissa

    "Gary Townsend (Spatial Mapping Ltd.)" wrote:

    > This is what i banged off in my spare time seems to work but you have to
    > include a reference to Microsoft Excel Object Library in your project
    > references. Alt+F11 then Tools>References and scroll till you find the
    > library and check the box. Then you can inser this code wherever you want.
    > HOwever i am not sure what you need to do with this once you have it open so
    > it may or may not work.
    >
    > Dim obj As New Excel.Application
    > obj.Workbooks.Add ("C:\Pardus.xlt")
    > obj.Visible = True
    >
    > --
    > ===============================
    > Gary Townsend
    > Database & Application Developer
    > Spatial Mapping Ltd.
    >
    > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > Not trying to code excel. Trying to code *Access* to open an excel file.
    > >
    > > "Wayne-in-Manchester" wrote:
    > >
    > > > Sorry to say I have never coded excel - am sure someone on this site

    > will be
    > > > able to supply you with an answer
    > > >
    > > >
    > > >

    >
    >
    >
     
  12. dogmelissa

    dogmelissa
    Expand Collapse
    Guest

    Gary,

    No need to reply! I figured out which references I needed (which is a really
    weird process), and adjusted the code for my files and put it in all 3 places
    where I have OnClick commands for each spreadsheet I wanted to open. Now it's
    working perfectly!!

    Thanks so much!
    Melissa

    "dogmelissa" wrote:

    > Gary,
    > I might be having a blond moment... what do you mean by needing to include
    > an excel reference in my project references?
    > I also posted a new post to the Google group you linked to (the specific
    > topic was from 2003 and no longer accessible for new posts).
    > Thanks much for you help!
    > Melissa
    >
    > "Gary Townsend (Spatial Mapping Ltd.)" wrote:
    >
    > > This is what i banged off in my spare time seems to work but you have to
    > > include a reference to Microsoft Excel Object Library in your project
    > > references. Alt+F11 then Tools>References and scroll till you find the
    > > library and check the box. Then you can inser this code wherever you want.
    > > HOwever i am not sure what you need to do with this once you have it open so
    > > it may or may not work.
    > >
    > > Dim obj As New Excel.Application
    > > obj.Workbooks.Add ("C:\Pardus.xlt")
    > > obj.Visible = True
    > >
    > > --
    > > ===============================
    > > Gary Townsend
    > > Database & Application Developer
    > > Spatial Mapping Ltd.
    > >
    > > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > > Not trying to code excel. Trying to code *Access* to open an excel file.
    > > >
    > > > "Wayne-in-Manchester" wrote:
    > > >
    > > > > Sorry to say I have never coded excel - am sure someone on this site

    > > will be
    > > > > able to supply you with an answer
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
  13. No problem it can be a bit confusing.

    Here i'll post some links to screenshots showing you what i refer to.

    In your code window go to Tools Menu and click on references like in this
    picture
    http://www.townsends.org/images/Misc/ToolsReferences.jpg
    THen the window below will open and scroll down till you see something
    similar to the entry i have higlighted below
    http://www.townsends.org/images/Misc/ObjectLibraries.jpg

    This will only work though if you have excel installed on your machine,
    which i assume you probably do.
    This will clear up the error you are getting.

    "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    news:104ADCE8-C892-4DD4-AF43-68F439B71A00@microsoft.com...
    > Gary,
    > I might be having a blond moment... what do you mean by needing to include
    > an excel reference in my project references?
    > I also posted a new post to the Google group you linked to (the specific
    > topic was from 2003 and no longer accessible for new posts).
    > Thanks much for you help!
    > Melissa
    >
    > "Gary Townsend (Spatial Mapping Ltd.)" wrote:
    >
    > > This is what i banged off in my spare time seems to work but you have to
    > > include a reference to Microsoft Excel Object Library in your project
    > > references. Alt+F11 then Tools>References and scroll till you find the
    > > library and check the box. Then you can inser this code wherever you

    want.
    > > HOwever i am not sure what you need to do with this once you have it

    open so
    > > it may or may not work.
    > >
    > > Dim obj As New Excel.Application
    > > obj.Workbooks.Add ("C:\Pardus.xlt")
    > > obj.Visible = True
    > >
    > > --
    > > ===============================
    > > Gary Townsend
    > > Database & Application Developer
    > > Spatial Mapping Ltd.
    > >
    > > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > > Not trying to code excel. Trying to code *Access* to open an excel

    file.
    > > >
    > > > "Wayne-in-Manchester" wrote:
    > > >
    > > > > Sorry to say I have never coded excel - am sure someone on this site

    > > will be
    > > > > able to supply you with an answer
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
  14. Glad you found it. Yes it is a wierd process. I'm glad you got it working.
    :)

    --
    ===============================
    Gary Townsend
    Database & Application Developer
    Spatial Mapping Ltd.

    "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    news:ABAA5492-5B47-4BFF-B0B7-C256B956D5EE@microsoft.com...
    > Gary,
    >
    > No need to reply! I figured out which references I needed (which is a

    really
    > weird process), and adjusted the code for my files and put it in all 3

    places
    > where I have OnClick commands for each spreadsheet I wanted to open. Now

    it's
    > working perfectly!!
    >
    > Thanks so much!
    > Melissa
    >
    > "dogmelissa" wrote:
    >
    > > Gary,
    > > I might be having a blond moment... what do you mean by needing to

    include
    > > an excel reference in my project references?
    > > I also posted a new post to the Google group you linked to (the specific
    > > topic was from 2003 and no longer accessible for new posts).
    > > Thanks much for you help!
    > > Melissa
    > >
    > > "Gary Townsend (Spatial Mapping Ltd.)" wrote:
    > >
    > > > This is what i banged off in my spare time seems to work but you have

    to
    > > > include a reference to Microsoft Excel Object Library in your project
    > > > references. Alt+F11 then Tools>References and scroll till you find the
    > > > library and check the box. Then you can inser this code wherever you

    want.
    > > > HOwever i am not sure what you need to do with this once you have it

    open so
    > > > it may or may not work.
    > > >
    > > > Dim obj As New Excel.Application
    > > > obj.Workbooks.Add ("C:\Pardus.xlt")
    > > > obj.Visible = True
    > > >
    > > > --
    > > > ===============================
    > > > Gary Townsend
    > > > Database & Application Developer
    > > > Spatial Mapping Ltd.
    > > >
    > > > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > > > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > > > Not trying to code excel. Trying to code *Access* to open an excel

    file.
    > > > >
    > > > > "Wayne-in-Manchester" wrote:
    > > > >
    > > > > > Sorry to say I have never coded excel - am sure someone on this

    site
    > > > will be
    > > > > > able to supply you with an answer
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >
     
  15. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Given what you're doing, try the following:

    Private Sub NewTakeoff_Click()

    Dim ExcelObj As Object

    Set ExcelObj = CreateObject("Excel.Application")
    ExcelObj.Workbooks.Add ("C:\~~~\Corona Material Takeoff Sheet.xlt")
    ExcelObj.Visible = True
    ExcelObj.Run ("Auto_Open")
    Set ExcelObj = Nothing

    End Sub

    and don't bother setting the reference to Excel. This has the advantage that
    it will work even on machines where the user has a different version of
    Excel than you do. Not only that, but even if the user doesn't have Excel
    installed, most of your application will still work (just that particular
    bit of code won't) It also avoids declaring ExcelObj as a New object. (While
    that may be how it's done in .Net, it's not a good idea in VBA, and wasn't a
    good idea in VB)

    This is known as "Late Binding" (as opposed to "Early Binding", which is
    when you have a reference set)

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    news:1E593EDF-0357-499F-B040-1ECAE886D81E@microsoft.com...
    > Gary,
    > Thanks for trying... I looked at that link and tried the code that worked
    > for the other person trying. However, mine is giving me an error on the

    first
    > line.
    > Code is as follows:
    > Private Sub NewTakeoff_Click()
    >
    > Dim ExcelObj As New Excel.Application
    > ExcelObj.Workbooks.Add ("C:\~~~\Corona Material Takeoff Sheet.xlt")
    > ExcelObj.Visible = True
    > ExcelObj.Run ("Auto_Open")
    > Set ExcelObj = Nothing
    >
    > End Sub
    >
    > and the error is highliting the Dim ExcelObj line with the following text:
    > "Compile error: User-defined type not defined"
    > Any thoughts? Or should I post this to the link you gave me?
    >
    > Melissa
    >
    >
    > "Gary Townsend (Spatial Mapping Ltd.)" wrote:
    >
    > > I would try this link it seems they were discussing the same idea your
    > > trying to do
    > >
    > >

    http://groups.google.ca/group/micro...4dd011/6c4130d98cbaf48b?lnk=st&q=open+excel+t
    emplate&rnum=5&hl=en#6c4130d98cbaf48b
    > >
    > > its long and ugly but it may do the trick for you
    > >
    > > I ws playing around with using the Call Shell() Command in VBA but that

    does
    > > the same thing you describe above in that it just opens the template.
    > >
    > > Gary Townsend
    > > Spatial Mapping Ltd.
    > > "dogmelissa" <dogmelissa@discussions.microsoft.com> wrote in message
    > > news:91F633C7-686E-4807-999B-B58785D941EF@microsoft.com...
    > > > Not trying to code excel. Trying to code *Access* to open an excel

    file.
    > > >
    > > > "Wayne-in-Manchester" wrote:
    > > >
    > > > > Sorry to say I have never coded excel - am sure someone on this site

    > > will be
    > > > > able to supply you with an answer
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     

Share This Page