|
-
Nov 16th, 2000, 01:45 PM
#1
Thread Starter
Lively Member
I have a form with 2 buttons. This program is suppose to call setup and readdata routine from module1 when I click cmd1 inside from1. My problem started with the statement
"For each c in selection" I get the error message <oject required> for this statement.
I thought i have already dim c as excel.range inside the module 1. Can somebody please help.
Regards
'form1
private sub cmd1_click()
setup
ReadData("A1:C5")
end sub
private sub cmd2_click()
set appxls = nothing
set wkbook = nothing
end sub
' Module 1
Option Explicit
Public appXls As Excel.Application
Public wkBook As Excel.Workbook
Sub setUp()
Dim mfile$
On Error Resume Next
Set appXls = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set appXls = CreateObject("Excel.Application")
End If
Err.Clear
On Error GoTo 0
mfile = "c:\test\ABCD.xls"
Set wkBook = appXls.Workbooks.Open(mfile)
End Sub
Sub cleanUp()
appXls.Quit
Set appXls = Nothing
Set wkBook = Nothing
End Sub
Sub ReadData(myRange As String)
Dim c As Excel.Range
With appXls.ActiveSheet
.Range(myRange).Select
For Each c In Selection
......events
.......events
next c
end with
end sub
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
|