|
-
Jul 13th, 2010, 09:55 PM
#1
Thread Starter
New Member
Error loading DLL when use "workbooks.add" on another computer!
Hello,
I have a problem with my program. I have a code as follow:
Code:
Dim Ex As New Excel.Application
Dim aa As Excel.Workbook
Dim ws As Excel.Worksheet
Set aa = Ex.Workbooks.Add
aa.SaveAs ("C:\Hong.xls")
Set ws = aa.Sheets(1)
Cells(1, 1) = Time
For i = 2 To 24
Cells(1, i) = i
Next
aa.Save
aa.Close: Set aa = Nothing: Set Ex = Nothing
I wrote it on my computer, use VB6.0 and Office 2003. So I used reference: "Excel 11.0 Object Library". The program run perfectly on my computer.
But I want to use it with another computer which couldn't install Office. So I copied Office 97 (it can run instantly) to the computer and use reference: "Excel 8.0 Object Library". And the program always get error "loading DLL" at" "Set aa=Ex.Workbooks.Add"
I don't know how to solve this problem.
Please help me!
Thank you very much.
-
Jul 13th, 2010, 10:26 PM
#2
Re: Error loading DLL when use "workbooks.add" on another computer!
Before compiling your App, remove the reference to Excel and change the code to use Late Binding. This way your App will be Excel Version-independent, your code using late binding would be:
Code:
Dim Ex As Object
Dim aa As Object
Dim ws As Object
Set Ex = CreateObject("Excel.Application")
Set aa = Ex.Workbooks.Add
aa.SaveAs ("C:\Hong.xls")
Set ws = aa.Sheets(1)
Cells(1, 1) = Time
For i = 2 To 24
Cells(1, i) = i
Next
aa.Save
aa.Close
Set aa = Nothing
Set Ex = Nothing
Set ws = Nothing
-
Jul 15th, 2010, 06:33 AM
#3
Thread Starter
New Member
Re: Error loading DLL when use "workbooks.add" on another computer!
That's great. Thank you so much.
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
|