473,387 Members | 1,569 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,387 software developers and data experts.

Where is ThisWorkbook.Sheets("xx") ?? Unable to resolve 'ThisWorkbook' :: Interop to Excel

I am converting an EXCEL VBA application to Visual Basic (2003).

I am not having much luck finding how to convert statements containing
references to things like ThisWorkbook.Sheets("sheetname").

I am not using Visual Studio Tools (which may be my problem, tho I would
think that I don't really need the templates --- or do I??)

Eric
(Soory for the repost - I noticed a typo in my Subject)
Mar 15 '06 #1
4 4379

"Eric W" <no****@wzone.com> wrote in message
news:pa****************************@wzone.com...
I am converting an EXCEL VBA application to Visual Basic (2003).

I am not having much luck finding how to convert statements containing
references to things like ThisWorkbook.Sheets("sheetname").

I am not using Visual Studio Tools (which may be my problem, tho I would
think that I don't really need the templates --- or do I??)


Have you tried recording macros and seeing what the code looks like?

Mar 15 '06 #2
ThisWorkBook can be used inside VBA because it is an intrinsic object, but
from outside you need to retrieve the WorkBook from the Application
instance, usingh objApplication.ActiveWorkbook or
objApplication.WorkBooks.Item(xxx)

Which is your specific problem?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Eric W" <no****@wzone.com> escribió en el mensaje
news:pa****************************@wzone.com...
I am converting an EXCEL VBA application to Visual Basic (2003).

I am not having much luck finding how to convert statements containing
references to things like ThisWorkbook.Sheets("sheetname").

I am not using Visual Studio Tools (which may be my problem, tho I would
think that I don't really need the templates --- or do I??)

Eric
(Soory for the repost - I noticed a typo in my Subject)

Mar 15 '06 #3
In my Basic.Net code, I figured out that I can resolve the Application
references with the statements:
Dim ExcelWorkbook = Excel.Workbook
Dim ExcelWorksheet = Excel.ApplicationClass

That made the syntax errors go away. BUT if I try to do something
really simple like MsgBox(Application.Cells("A1")

I get an #Value! error in Excel.

Which when I think about it, I'm not assigning ExcelWorkbook nor
ExcelWorksheet to anything, so it's no wonder why I get an error.

So.......

How do I reference to actual Excel Object? (So that I can refer to cells,
ranges, and use Excel's functions.)

(My code didn't start Excel; Excel called me).
I don't have the Visual Studio Tools for Office (maybe I should buy it???)

On Wed, 15 Mar 2006 12:32:39 +0100, Carlos J. Quintero [VB MVP] wrote:
ThisWorkBook can be used inside VBA because it is an intrinsic object, but
from outside you need to retrieve the WorkBook from the Application
instance, usingh objApplication.ActiveWorkbook or
objApplication.WorkBooks.Item(xxx)

Which is your specific problem?


Mar 16 '06 #4
Hi,
(My code didn't start Excel; Excel called me).
I don't have the Visual Studio Tools for Office (maybe I should buy it???)


AFAIK, there are three ways to interact with Excel:

- Your code starts Excel externally
- You are creating an add-in for Excel using .NET.
- You are using VSTO to extend Excel instead of using VBA.

So, which is your case? How does Excel "call" you?

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


Mar 21 '06 #5

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

Similar topics

9
by: Scott Beavers | last post by:
I'm trying to create a form in Excel to sort from the form and take the data to another worksheet. I am very new to this and any help would be appreciated. I have a value in a cell that will...
5
by: msnews.microsoft.com | last post by:
Hi, I am having a problem that the gateway I am working with removes the "=" sign from values in the postfield that are empty. Example: page.asp?aa=&ff=&xx=12 become: page.asp?aa&ff&xx=12....
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
1
by: Rob R. Ainscough | last post by:
I keep getting this error message when I build my solution: Error: The dependency 'xxx.xx.xx, Version=1.0.2067.27633, Culture=neutral' in project 'xxx.xx.xx' cannot be copied to the run directory...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
0
by: Eric W | last post by:
I am converting an EXCEL VBA application to Visual Basic (2003). I am not having much luck finding how to convert statements containing references to things like ThisWorkbook.Sheets("sheetname")....
37
by: Jan Wagner | last post by:
Hi, can't figure this one out, what's the CSS way to specify the language? In HTML it would be simply an lang="xx" attribute, or XHTML xml:lang="xx", but, how about in CSS? This would be...
3
by: jason | last post by:
I've been playing around with new (for 2.0) membershp functionality. I was able to build a simple login form that secures a directory on a project I built locally on my development desktop. ...
5
by: Noozer | last post by:
I'm looking for a "smart folder" program to run on my Windows XP machine. I'm not having any luck finding it and think the logic behind the program is pretty simple, but I'm not sure how I'd...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.