Results 1 to 4 of 4

Thread: Quick question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    20

    Quick question

    Can anyone tell me why this code will not work on my 98 machine??
    Private Sub Command1_Click()

    Dim xlapp As Excel.Application
    Dim xlbook As Excel.Workbook
    Dim xlsheet As Excel.Worksheet

    Set xlapp = New Excel.Application
    Set xlbook = xlapp.Workbooks.Add
    Set xlsheet = xlbook.Worksheets.Add

    xlsheet.Cells(3, 1).Value = "ASDFASDFA"
    xlsheet.SaveAs "C:\Documents and Settings\Chris Wilson\Desktop\temp.xls"
    xlapp.Quit
    Set xlapp = Nothing
    Set xlbook = Nothing
    Set xlsheet = Nothing

    End Sub

    It compiles and runs fine on my XP machine but when it encounters the set xlsheet line it gives me a runtime error!!??

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    My guess it's because the reference you're using on the XP machine is for Office XP.... and you don't have Office XP in the Win98 machine.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    20
    I am running Office 2000 on both machines....this snippet of code I posted I actually wrote on the 98 and received the errors. I then cut an pasted it onto the XP machine and it runs fine. I didn't see any reason why it should not compile and run, simple reference to Excel to open, write some letters, and then close??!!

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    rodman70,

    Thing like this could be easy to miss; One thing that you have to do is make sure that the 98 machine OS and Office has been updated to the latest versions and service packs.

    The thing I see the most is that when people install Office they do not apply the updates which have caused many a program to fail. The Office on the XP machine may have automatically been updated and current and that is why it works.


    This is just a thought!!! Take a look at the about box of both machines, see what is there.

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