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

GetType and ApplicationClass

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

"Public member 'GetType' on type 'ApplicationClass' 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.Application.
TypeName returns ApplicationClass.

Am I using GetType correctly?

Private Sub CheckGetType(ByRef appWord As Word.Application)
With lstOut
Try
Dim strType As String = appWord.GetType.ToString
.Items.Add("GetType: Detected " & strType)
Catch ex As Exception
.Items.Add("GetType(1): " & ex.Message)
End Try
Try
Dim strType As String = gappWord.GetType.ToString
.Items.Add("GetType: Detected " & strType)
Catch ex As Exception
.Items.Add("GetType(2): " & ex.Message)
End Try
End With
End Sub

--
http://www.standards.com/; See Howard Kaikow's web site.
Nov 21 '05 #1
4 2836
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****@standards.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationClass' 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.Application.
TypeName returns ApplicationClass.

Am I using GetType correctly?

Private Sub CheckGetType(ByRef appWord As Word.Application)
With lstOut
Try
Dim strType As String = appWord.GetType.ToString
.Items.Add("GetType: Detected " & strType)
Catch ex As Exception
.Items.Add("GetType(1): " & ex.Message)
End Try
Try
Dim strType As String = gappWord.GetType.ToString
.Items.Add("GetType: Detected " & strType)
Catch ex As Exception
.Items.Add("GetType(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******@spammersgoawaydotnetservices.biz> wrote in message
news:ee**************@TK2MSFTNGP15.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****@standards.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationClass' not found"
Is Word.Application 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****@standards.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
For the code below, for both appWord and gappWord, I get the error

"Public member 'GetType' on type 'ApplicationClass' not found"
Is Word.Application an Interface?


Word.Application 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
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...
6
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;...
1
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;...
0
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...
0
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...
1
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...
1
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.