UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Error with Dim AppExcel as Excel.Application    
 
   
awolterm
post Feb 19 2008, 10:19 AM
Post #1

UtterAccess Guru
Posts: 547
From: Maryland



I keep getting a complie error:
ser - defined type not defined.
CODE
  Private Sub openExcel_Click()
'make a reference to Microsoft excel 9.0 object library
[b]Dim AppExcel As Excel.Application[/b]
Dim wSheet As Worksheet
Dim wBook As Workbook
Set AppExcel = CreateObject("Excel.Application")
If AppExcel.Workbooks.Count = 0 Then
Debug.Print "Adding a new Workbook"
Set wBook = AppExcel.Workbooks.Add
End If
Set wSheet = AppExcel.Sheets(1)
wSheet.Cells(2, 1).Value = "Welcome"
wSheet.Cells(3, 1).Value = "To"
wSheet.Cells(4, 1).Value = "UtterAccess"
AppExcel.Visible = True
End Sub

Anyone know what I get this? I got this code out of the code archive for opening an excel file. It also seems any other code that has the line dim x as excel.application, I get an error.
Thanks for the help.
Go to the top of the page
 
+
fkegley
post Feb 19 2008, 10:23 AM
Post #2

UtterAccess VIP
Posts: 23,630
From: Mississippi



Yes, I believe the problem is that you have not set a reference to the Excel Object library for your computer.
Go to the top of the page
 
+
awolterm
post Feb 19 2008, 10:31 AM
Post #3

UtterAccess Guru
Posts: 547
From: Maryland



Ok 1. How would I do that?
2. How come I can run other db's that use the dim x as excel.application? I have run it out of a couple people's postings in the code archive; however when I move it all to my DB, no go.
Go to the top of the page
 
+
freakazeud
post Feb 19 2008, 10:40 AM
Post #4

UtterAccess VIP
Posts: 31,413
From: NC, USA



Because references don't copy over. Set them manually through VBA editor--Tools--References...or use late binding to avoid the dependency on reference all together.
HTH
Good luck
Go to the top of the page
 
+
awolterm
post Feb 19 2008, 10:44 AM
Post #5

UtterAccess Guru
Posts: 547
From: Maryland



Can you explain more about that?
Go to the top of the page
 
+
freakazeud
post Feb 19 2008, 11:07 AM
Post #6

UtterAccess VIP
Posts: 31,413
From: NC, USA



About what?
HTH
Good luck
Go to the top of the page
 
+
awolterm
post Feb 19 2008, 11:15 AM
Post #7

UtterAccess Guru
Posts: 547
From: Maryland



Sorry I was not specific....

How do I code it with late binding so I don't have to deal with the references?

Sorry, I am just starting out with this excel automation stuff, so I am not quite familiar with the proceedures I need to follow in order to get it to talk.


Thanks for all the help.
Edited by: awolterm on Tue Feb 19 11:22:12 EST 2008.
Go to the top of the page
 
+
freakazeud
post Feb 19 2008, 11:25 AM
Post #8

UtterAccess VIP
Posts: 31,413
From: NC, USA



Hi,
you can read about it in any or all of these:
01
02
03
04
HTH
Good luck
Go to the top of the page
 
+
awolterm
post Feb 19 2008, 11:37 AM
Post #9

UtterAccess Guru
Posts: 547
From: Maryland



Thank you!
Go to the top of the page
 
+
freakazeud
post Feb 19 2008, 11:46 AM
Post #10

UtterAccess VIP
Posts: 31,413
From: NC, USA



You're welcome.
Good luck on future projects!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 29th August 2014 - 11:14 AM