473,548 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetType and ApplicationClas s

For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationCla ss' not found"

I realize the test for appWord is superflous as the parameter is passed in
as a known type, but gappWord is has a scope of the class, so a test of the
type is valid (making believe the sub does not know the pre-ordained type).

TypeOf returns Word.Applicatio n.
TypeName returns ApplicationClas s.

Am I using GetType correctly?

Private Sub CheckGetType(By Ref appWord As Word.Applicatio n)
With lstOut
Try
Dim strType As String = appWord.GetType .ToString
.Items.Add("Get Type: Detected " & strType)
Catch ex As Exception
.Items.Add("Get Type(1): " & ex.Message)
End Try
Try
Dim strType As String = gappWord.GetTyp e.ToString
.Items.Add("Get Type: Detected " & strType)
Catch ex As Exception
.Items.Add("Get Type(2): " & ex.Message)
End Try
End With
End Sub

--
http://www.standards.com/; See Howard Kaikow's web site.
Nov 21 '05 #1
4 2852
CT
Howard,

I'm not sure what it is you're trying to do, but you can type case using the
CType function, like this:

Dim strType As String = CType(appWord, Object).GetType .ToString

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105

"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationCla ss' not found"

I realize the test for appWord is superflous as the parameter is passed in
as a known type, but gappWord is has a scope of the class, so a test of
the
type is valid (making believe the sub does not know the pre-ordained
type).

TypeOf returns Word.Applicatio n.
TypeName returns ApplicationClas s.

Am I using GetType correctly?

Private Sub CheckGetType(By Ref appWord As Word.Applicatio n)
With lstOut
Try
Dim strType As String = appWord.GetType .ToString
.Items.Add("Get Type: Detected " & strType)
Catch ex As Exception
.Items.Add("Get Type(1): " & ex.Message)
End Try
Try
Dim strType As String = gappWord.GetTyp e.ToString
.Items.Add("Get Type: Detected " & strType)
Catch ex As Exception
.Items.Add("Get Type(2): " & ex.Message)
End Try
End With
End Sub

--
http://www.standards.com/; See Howard Kaikow's web site.

Nov 21 '05 #2
"CT" <ca******@spamm ersgoawaydotnet services.biz> wrote in message
news:ee******** ******@TK2MSFTN GP15.phx.gbl...
Howard,

I'm not sure what it is you're trying to do, but you can type case using the CType function, like this:

Dim strType As String = CType(appWord, Object).GetType .ToString


Thanx.
I'll give it a try.

I had thought about casting, but I'm trying to detect the type, so casting
seemed inappropriate.
Nov 21 '05 #3
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationCla ss' not found"
Is Word.Applicatio n an Interface?
If so, it would have to /explicitly/ include a GetType function for you
to use it in this way.

GetType( appWord )

/might/ do what you want (haven't tried it, I'll admit), or you could use

DirectCast( appWord, Object ).GetType

instead. GetType is definitely defined for an Object and /every/
reference Type derives from Object.
I had thought about casting, but I'm trying to detect the type, so
casting seemed inappropriate.


Don't confuse "casting" with "converting ". Casting tells the compiler

Take *this* and treat it like one of *those*

as in

DirectCast( appWord, Object )

(I recommend DirectCast over CType, because the latter tries to be
"clever" and do type conversions for you as well).

Converting /would/ lose the original type information, something like

Dim dtThen as Date = CDate( "2001-01-01" )
Dim sThen as String _
= dtThen.ToString ()

HTH,
Phill W.
Nov 21 '05 #4
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:d9******** **@yarrow.open. ac.uk...
"Howard Kaikow" <ka****@standar ds.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationCla ss' not found"
Is Word.Applicatio n an Interface?


Word.Applicatio n in the ProgID for Word.
If so, it would have to /explicitly/ include a GetType function for you
to use it in this way.

GetType( appWord )
That's what I was using.
/might/ do what you want (haven't tried it, I'll admit), or you could use

DirectCast( appWord, Object ).GetType

instead. GetType is definitely defined for an Object and /every/
reference Type derives from Object.


I used CType and the problem was resolved.

DirectCast would likely work too.

My concern was hat I had to cast using GetType, but not with TypeOf or
TypeName.
Nov 21 '05 #5

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

Similar topics

1
509
by: MSNEWS | last post by:
Hi I'm using the word.applicationclass within my vb.net application to convert some word documents to text files. Is there anyway I can disable macros whilst loading the document, in Word I can do that by running winword /a, but not sure how to add the switch using the word.applicationclass object. Thanks
6
5356
by: LEBRUN Thomas | last post by:
Hello :) I would like to use Outlook 2003 in my application so for that, i've added the referece to Outlook 11.0 Object Model to my project. Then, I try this simple code : using System; using Microsoft.Office.Interop.Outlook;
1
2604
by: Markusek Peter | last post by:
I got this error: Exception Details: System.Runtime.InteropServices.COMException: Server execution failed Source Error: Line 29: protected System.Web.UI.HtmlControls.HtmlGenericControl zzz; Line 30: protected System.Web.UI.WebControls.Button Button1; Line 31: private Word.ApplicationClass oWordApp = new Word.ApplicationClass();
0
233
by: Chris Gatto | last post by:
Hello, I'm hoping that someone out there has a wonderfully simple answer for this - it seems like it should. I am using an ASP.Net application to try and create calendar appointments in user's outlook mailboxes. I have a reference to the Outlook 11 COM object in my project. Also, I am using identity_ impersonate = true in my web.config...
0
896
by: Roger | last post by:
on my development iis - I has win xp installed. can run the aspx page fine and create the outlook.applicationclass. but when I move the page to my production IIS server, which is win 2003 server, it cannot create the applicationclass object. The web site is setup to run on an application pool where the identity user is a domain user that...
1
7024
by: PhilD | last post by:
My C#.NET console app checks a public folder every 24 hours for incoming emails. For each unread email in the folder, it copies any attachments to the network, then loads the contents of these files into a SQL Server database, and marks the email as read. My problem is that in the loop that checks for all the Unread emails in the folder, as...
1
1461
by: Shar Shar | last post by:
Hi All, Actually I want to use "Word.ApplicationClass" class for opening a word file. And do following things, 1) Open word file. 2) Insert text in bookmark field. 3) Print resultant file as pdf. Has anyone solution how can I do this programmatically in C#.
1
7255
by: inxanu | last post by:
First of all, I am unsure as to where to post it, so please let me know (or move it) to where it should be. I create an instance of word as follows Word.ApplicationClass wd = new Word.ApplicationClass(); wd.Caption = "My Word"; int wordHandle = FindWindow("Opusapp", wd.Caption); Questions:
0
7518
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7444
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7954
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6039
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.