|
-
Jun 16th, 2004, 11:47 PM
#1
Thread Starter
New Member
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..
-
Jun 17th, 2004, 01:18 AM
#2
Are you sure both machines have the same version of Excel? Just checking
-
Jun 17th, 2004, 01:37 AM
#3
Thread Starter
New Member
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
-
Jun 17th, 2004, 01:47 AM
#4
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.
-
Jun 17th, 2004, 01:49 AM
#5
Hyperactive Member
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
-
Jun 17th, 2004, 09:45 PM
#6
Thread Starter
New Member
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
-
Jun 18th, 2004, 02:17 AM
#7
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|