473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

missing code in XL range example

Hi All
I need to check that a Range name exists in an XL worksheet so I can
import data into it from Access VB code.

( I have found it is easiest to do a Transferspreadsheet to a named
range called "data"
eg.
DoCmd.TransferSpreadsheet acExport, 8, "qryXLExport",
"myworksheet.xls", True, "data"
DoEvents)

On the microsoft website, and other various sites I have found a code
snippet :-
-----------------------------------------------------------
Sub Find_Names()
' Loop through all names in workbook.
For Each n In ActiveWorkbook.Names
.........

Next
MsgBox "No More Names!"
' Display message when finished.
End Sub
--------------------------------------------------------
I really need to know how to define N as an XL range in VB code
ie.
For Each N In ........

I cannot find an example of how to declare N
eg
dim n as range
dim n as xl.range

Thanks for any ideas

Ray

Feb 4 '07 #1
4 1738
On Feb 4, 6:11 pm, "Accessed" <rwat...@westnet.com.auwrote:
Hi All
I need to check that a Range name exists in an XL worksheet so I can
import data into it from Access VB code.

( I have found it is easiest to do a Transferspreadsheet to a named
range called "data"
eg.
DoCmd.TransferSpreadsheet acExport, 8, "qryXLExport",
"myworksheet.xls", True, "data"
DoEvents)

On the microsoft website, and other various sites I have found a code
snippet :-
-----------------------------------------------------------
Sub Find_Names()
' Loop through all names in workbook.
For Each n In ActiveWorkbook.Names
.........

Next
MsgBox "No More Names!"
' Display message when finished.
End Sub
--------------------------------------------------------
I really need to know how to define N as an XL range in VB code
ie.
For Each N In ........

I cannot find an example of how to declare N
eg
dim n as range
dim n as xl.range

Thanks for any ideas

Ray
Did you try...

Dim N As Excel.Name

....?

Feb 5 '07 #2
Good suggestion, but it doesnt recognize that in Access 2003 at
least . Compiling produces ...
"User defined Type not defined"

( was that an access 97 version you were quoting ?)

I tried

Dim xl As Object
Dim N As Object
Set xl = CreateObject(Class:="Excel.application")
Set N = CreateObject(Class:="Excel.name")
and
Set N = CreateObject(Class:="Excel.range")

with no success too

Thanks for the suggestion though
Did you try...

Dim N As Excel.Name
Feb 5 '07 #3
On Feb 4, 8:31 pm, "Accessed" <rwat...@westnet.com.auwrote:
Good suggestion, but it doesnt recognize that in Access 2003 at
least . Compiling produces ...
"User defined Type not defined"

( was that an access 97 version you were quoting ?)
No, Access 2000.

The declaration I suggested uses early binding which means that it
needs a reference, as in...

Tools References...

....in the VBA editor window. In my case it was

Microsoft Excel 9.0 Object Library

Your version number may be different (i.e., "11" for Office 2003).

Feb 5 '07 #4
Adding the Library reference "worked" in as far as I can declare a
variable
but ...
Dim n As Excel.Name ' works ok
For Each n In .ActiveWorkbook.Names
' Check to see if the name refers to the ActiveSheet.
Debug.Print n.Name
Next
produces an error message in the
[For Each n In .ActiveWorkbook.Names] line ..
"Object doesnt support this property or method"

Obviously I am mismatching functionality here.
I will have a go using the library functions now that I have the
reference in my app.

Thanks for the followup.
The declaration I suggested uses early binding which means that it
needs a reference, as in...

Tools References...

...in the VBA editor window. In my case it was

Microsoft Excel 9.0 Object Library

Your version number may be different (i.e., "11" for Office 2003).

Feb 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
5
by: Annette Massie | last post by:
I have a park permit tracking database where I was thinking of having the user enter all the park permits individually, however realized that in a day, a park could host many daily users. So if 100...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
0
by: kris | last post by:
hi can any one help me out, i have written a code for Word Indexing using Dll's i think this is an incomplete code for WORD INDEX. I had encountered this error "Error! No index entries found"...
77
by: Ville Vainio | last post by:
I tried to clear a list today (which I do rather rarely, considering that just doing l = works most of the time) and was shocked, SHOCKED to notice that there is no clear() method. Dicts have it,...
67
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 ...
9
by: CoCoCha | last post by:
Hi, I am trying to run a simple macro in excel vba to create a new email and attach two spreadsheets. But it won't work. It stops at the first line everytime. Dim objOutlook As...
2
by: Joe Goldthwaite | last post by:
I've been playing with Python a bit. Doing little performance benchmarks and working with Psyco. It's been fun and I've been learning a lot. For example, in a previous post, I was looking for a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.