|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GetType and ApplicationClass"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 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 -- Show quoteHide quoteCarsten Thomsen Enterprise Development with VS .NET, UML, AND MSF http://www.apress.com/book/bookDisplay.html?bID=105 "Howard Kaikow" <kai***@standards.com> wrote in message news:%23oTjADmeFHA.3620@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. > > "CT" <carstent@spammersgoawaydotnetservices.biz> wrote in message Thanx.news:eefduEveFHA.2888@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 I'll give it a try. I had thought about casting, but I'm trying to detect the type, so casting seemed inappropriate. "Howard Kaikow" <kai***@standards.com> wrote in message Is Word.Application an Interface?news:%23oTjADmeFHA.3620@TK2MSFTNGP09.phx.gbl... > For the code below, for both appWord and gappWord, I get the error > > "Public member 'GetType' on type 'ApplicationClass' not found" 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 Don't confuse "casting" with "converting". Casting tells the compiler> casting seemed inappropriate. 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. "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message Word.Application in the ProgID for Word.news:d9r93e$oor$1@yarrow.open.ac.uk... > "Howard Kaikow" <kai***@standards.com> wrote in message > news:%23oTjADmeFHA.3620@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 That's what I was using.> to use it in this way. > > GetType( appWord ) > I used CType and the problem was resolved.> /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. DirectCast would likely work too. My concern was hat I had to cast using GetType, but not with TypeOf or TypeName.
VS Pro 2005 vis a vis VSTO 2005
C# to VB crossover questions hide control based on SQLS2K column level permission Update Element in ArrayList Structure About MessageQueue Problem Large fonts setting (120DPI) Add record to Access Databases Q: Status Bar Vanishes Public vs Shared Using JPG stills to make a "Video" file |
|||||||||||||||||||||||