Results 1 to 7 of 7

Thread: problem exporting to excel... please help me....

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Location
    Indonesia
    Posts
    4

    Exclamation problem exporting to excel... please help me....

    Hi all,

    I have create a program using VB6, I used Win XP & Office XP. The problem is when I used it in Win 98 & Office XP I can't export my data from VB to excel. Here is the source code:

    Dim excApp as Excel.Application

    Private Sub Form_Load()
    set excApp = new Excel.Application

    excApp.Workbooks.Add
    excApp.ActiveWorkbook.ActiveSheet.Cells(1,1).Value="TEST"

    set excApp = Nothing
    End Sub

    I got no problem at all in WinXP, but in Win98 I got error "Error Automation"... anyone please help me asap....

    thanx a lot guys..

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Are you sure both machines have the same version of Excel? Just checking

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Location
    Indonesia
    Posts
    4
    yes, i used the same office, i installed it from the same cd.

    ow, just for information, i forget to put excApp.Visible=True (which you can put it anywhere you like before Set excApp = Nothing)

    anyone can help me please?


    thanks guys

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    One option is to write to a log file after each line of code in your Form_Load as that will pin point where the error is occurring.

  5. #5
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hi!

    Better try my version of excel ...it works for me on 98, Me, XP, 2000. I used to create reports and it worked pretty fine.

    [vb]Dim appExcel As Excel.Application
    Set appExcel = New Excel.Application

    'Will turn off all dialog box
    appExcel.DisplayAlerts = False

    'Will make it run in the background
    appExcel.Visible = False
    appExcel.ScreenUpdating = False

    'Will Open Bill.xls
    appExcel.Workbooks.Open FileName:=App.Path & "\Test.xls"
    appExcel.Worksheets("Sheet1").Select

    'Send data from TextBox to Excel
    appExcel.Range("A1").Value = Text1.Text

    'Will print copies and close and quit
    appExcel.Worksheets.PrintOut , , 1

    'Will close and save the excel file.
    appExcel.ActiveWorkbook.Close Savechanges:=True

    'Will quit excel
    appExcel.Quit
    Set appExcel = Nothing
    Exit Sub[/vb]

    I hope this helps!

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Location
    Indonesia
    Posts
    4
    Well, AvisSoft, I already tried your code... but it still doesn't work. I used office xp, and when i try to run your code I got this error message:

    Run-time Error: 1004
    Application-defined or object-defined error

    The error message is in the

    appExcel.Workbooks.Open FileName:=App.Path & "\Test.xls"

    I tried to chagne the filename but still got the same error message....

    And if I changed your code to like this:

    appExcel.Workbooks.Add
    appExcel.Worksheets("Sheet1").Select

    I got error message:

    Run-time Error: -2147417848 (80010108)
    Automation Error

    The error message is at the appExcel.Worksheets("Sheet1").Select line....


    I don't know whats wrong with my comp... help me anybody....

    thx

  7. #7
    Hyperactive Member AvisSoft's Avatar
    Join Date
    Sep 2002
    Location
    Chandigarh
    Posts
    459
    Hello!

    I hope you are setting the proper refrences to the Excel in VB. Also you i recommend that you better use the Save My Settings Wizard from XP and put those settings on 98 system. So what i finally think of this problem ?:

    1. Office is not installed properly on 98.
    2. You must not be setting the refrences in VB
    3. If you're getting Automation error then its a problem with 98 and Office and not VB.

    I hope if you try to look into the above deeply then your problem may get solved. My code is working fine on 98/Me/XP and 2000. Though here is the refrence i have used in VB:

    In the Project > References > Microsoft Excel 10.0 Object Library select this and then try my code.

    Thanks!
    Tapan Bhanot,
    CEO, Avis Software.
    Website: www.avissoftware.com

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