Results 1 to 11 of 11

Thread: Excel Exception...only on one computer?[RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Excel Exception...only on one computer?[RESOLVED]

    Hello. This code give me an error, but only on one computer. It works fine on other computers, except the Account Managers computer...fun huh? Maybe it is an Excel setting on her computer?
    VB Code:
    1. If sfd.ShowDialog = DialogResult.OK Then
    2.             strExcelFile = sfd.FileName
    3.             xlWBook.SaveAs(strExcelFile) 'LINE 1188
    4.         Else
    5.             Exit Sub
    6.         End If

    Here is the error:

    System.NullReferenceException: Object reference not set to an instance of an object.
    at Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)
    at AZShower.frmIncomeExcel.btnExportToExcel_Click(Object sender, EventArgs e) in C:\VB.NET\AZShower\Accounting\frmIncomeExcel.vb:line 1188

    Thanks for your time!
    Last edited by brendalisalowe; Nov 29th, 2005 at 11:33 AM.
    Brenda

    If it weren't for you guys, where would I be?

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    Re: Excel Exception...only on one computer?

    Looks like xlWBook is not set to an Excel workbook object when line 1188 is called. You need to check how and where xlWBook is set for this instance to find why the object is not being set.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Re: Excel Exception...only on one computer?

    But I don't understand because it is only on ONE computer that it doesn't work. Wouldn't it be some setting in Excel then?
    Brenda

    If it weren't for you guys, where would I be?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Excel Exception...only on one computer?

    Is everyone, including the Account Manager, running the same version of Excel?

    Is this one computer a laptop? I've had issues between desktops and laptops before.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Re: Excel Exception...only on one computer?

    Well, I kind of figured it out. It will run when using Office XP or Office 2003, but NOT Office 2000. Are there any plug-ins I can use? Or updates? Or what should I do?

    Thanks for the idea of checking the version....
    Brenda

    If it weren't for you guys, where would I be?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Re: Excel Exception...only on one computer?

    Has anyone ever used this kind of automation on Office 2000? Or can you just not do it?
    Brenda

    If it weren't for you guys, where would I be?

  7. #7
    New Member
    Join Date
    Oct 2005
    Posts
    8

    Re: Excel Exception...only on one computer?

    Given what you wrote, I'm guessing that the application was developed with a reference set to the Excel 10.0 Object Library (aka Excel XP). The object libraries are (for the most part **) forward compatible but not backward compatible.

    If this is the case, go through your code and change all your Excel object references from early binding to late binding. You'll get a slight performance penalty, but for most operations this isn't even noticable.


    ** Many developers use forward Excel object library compatibility without a hitch, but Microsoft has stated in ther migration whitepapers that early binding is preferred because there are a few forward compatibility issues.

  8. #8
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Re: Excel Exception...only on one computer?

    As said previously you need to reference an earlier version of Office (specifcally Office 2000 as that is the earliest version you app is running on). For some more information on doing that see here.

    Specifically this portion:

    The Office XP primary interop assemblies only work with Office XP. If you
    want your program to be backwards compatable with Office 2000, you need to
    create your own interop assemblies by referencing the Office 2000 libraries
    in your project.


    To do this, first install Office 2000 on your development machine (you can
    do a side-by-side install with Office XP, except for Outlook, if you specify
    a different destination directory during install.) Then, remove all the
    references in your project(s) to the Office libraries. Finally, create a
    new reference to the Office 2000 libraries -- e.g., for Microsoft Word 2000,
    select Add References, select COM tab, and add a reference to the Microsoft
    Word 9.0 Object Library. Visual Studio will create an interop assembly for
    Word 2000/Office 2000.


    The new Office 2000 interop assembly should be forward compatable with
    Office XP and Office 2003

    Hope this helps!

  9. #9
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Re: Excel Exception...only on one computer?

    Silly question here but..is Office 2000 installed onto the development machine?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Re: Excel Exception...only on one computer?

    I just installed it and found the 9.0 object library. Thanks Bob! It works now!
    Brenda

    If it weren't for you guys, where would I be?

  11. #11
    Addicted Member BobTheBuilder.'s Avatar
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    149

    Thumbs up Re: Excel Exception...only on one computer?[RESOLVED]

    Sure thing!

Posting Permissions

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



Click Here to Expand Forum to Full Width