Results 1 to 15 of 15
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    I have the following simple code and have no idea why it is throwing an error:

    Dim appExcel As Excel.Application
    Dim wkb As Excel.Workbook
    Dim wst As Excel.Worksheet
    Dim intCount As Integer
    Dim strSql As String
    Dim strSql2 As String
    Dim strSection As String
    Dim intSequence As Integer


    strSql = ...
    strSql2 = "...

    Set appExcel = CreateObject("Excel.Application")


    Set rstStudents = CurrentDb.OpenRecordset(strSql, dbOpenDynaset)
    Set rstClasses = CurrentDb.OpenRecordset(strSql2, dbOpenDynaset)

    Set wkb = appExcel.Workbooks.Add()
    Set wst = wkb.Sheets(1)
    wst.Activate
    appExcel.Visible = True

    When it gets to workbooks.add I get "Method add of object workbooks failed"

    Any ideas?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Does it make a difference if you omit the brackets?

    Set wkb = appExcel.Workbooks.Add

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='787342' date='03-Aug-2009 17:32']Does it make a difference if you omit the brackets?

    Set wkb = appExcel.Workbooks.Add[/quote]
    No, I had tried that first.
    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Is there other code between the line

    Set appExcel = CreateObject("Excel.Application")

    and

    Set wkb = appExcel.Workbooks.Add()

    that you haven't posted?

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='787387' date='03-Aug-2009 21:10']Is there other code between the line

    Set appExcel = CreateObject("Excel.Application")

    and

    Set wkb = appExcel.Workbooks.Add()

    that you haven't posted?[/quote]
    no- just the rest of strsql that is just a string that I checked already works.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The code itself is correct, so there appears to be a problem with the Excel object. Does the problem persist after restarting your PC?

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='787393' date='03-Aug-2009 22:10']The code itself is correct, so there appears to be a problem with the Excel object. Does the problem persist after restarting your PC?[/quote]
    yes. I think it might be because I have both 2007 and the beta of 2010 installed on my computer. I am going to try this on a simpler instal and see what happens.
    Thanks

  8. #8
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='ZAve' post='787436' date='04-Aug-2009 17:38']yes. I think it might be because I have both 2007 and the beta of 2010 installed on my computer. I am going to try this on a simpler instal and see what happens.
    Thanks[/quote]
    Is Office 2010 on its' way?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='patt' post='787439' date='04-Aug-2009 08:25']Is Office 2010 on its' way?[/quote]
    See Microsoft Office 2010 on Wikipedia.

  10. #10
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='HansV' post='787441' date='04-Aug-2009 17:41']See Microsoft Office 2010 on Wikipedia.[/quote]
    Thanks Hans.

  11. #11
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='787393' date='03-Aug-2009 22:10']The code itself is correct, so there appears to be a problem with the Excel object. Does the problem persist after restarting your PC?[/quote]
    due to some other issues also I uninstalled 2010 and 2007 then reinstalled only 2007, but I still have the issue. Very weird and annoying.Still have not had a chance to try it somewhere else

  12. #12
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='patt' post='787439' date='04-Aug-2009 07:25']Is Office 2010 on its' way?[/quote]
    I ave been using the technical preview (beta). Not any major changes in the front end of Access, did not yet get a chance to sue the new macro editor which look interesting. Also they redid the build button in creating Dfunctions etc. However, Outlook 2010 is great.

  13. #13
    Lounger
    Join Date
    Jan 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any chance graphing will work again in Access 2010?

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    This is not the place to discuss Office 2010 Beta. Moreover, this topic is about starting Excel from Access, please don't hijack it.

  15. #15
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Jerusalem, Israel
    Posts
    708
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='787562' date='04-Aug-2009 20:52']This is not the place to discuss Office 2010 Beta. Moreover, this topic is about starting Excel from Access, please don't hijack it.[/quote]
    Sorry you are correct

Posting Permissions

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