473,290 Members | 1,957 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,290 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 4375

"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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.