|
I am trying to extract the words and punctuation from a word document. I am having a heck of a time finding thorough documentation on the strings to pass (Ex: L"Document", L"Words", L”Open”, etc.) and the patterns to use in the calls. The code I am using has been extracted and tweaked from the MS support site examples. What I have found is a good start except it all stops short of showing how to grab the words from the file. This code runs but it does not actually pull the words from the file in the line:
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, pDoc.pdispVal, L"Words", 1, parm[0]);
The Code:
HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...) {
// Reduced code...
// Get DISPID for name passed...
hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
// Handle special-case for property-puts!
if(autoType & DISPATCH_PROPERTYPUT) {
dp.cNamedArgs = 1;
dp.rgdispidNamedArgs = &dispidNamed;
}
// Make the call!
hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL);
return hr;
}
int main(int argc, char* argv[]){
// Initialize the OLE Library...
OleInitialize(NULL);
// Set WordApp = CreateObject Word.Application
{
CLSID clsid;
CLSIDFromProgID(L"Word.Application", &clsid);
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER, IID_IDispatch, (void **)&rVal.pdispVal);
// WordApp . DisplayAlerts = 0
rVal.vt = VT_I4;
rVal.lVal = 0;
AutoWrap(DISPATCH_PROPERTYPUT, NULL, pWordApp.pdispVal, L"DisplayAlerts", 1, rVal);
VariantClear(&rVal);
// WordApp . Documents . Open wordPath , 0 , 1
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &pDoc, pWordApp.pdispVal,
L"Documents", 0);
parm[1].vt = VT_I4;
parm[1].lVal = 0;
parm[2].vt = VT_I4;
parm[2].lVal = 1;
AutoWrap(DISPATCH_METHOD, NULL, pDoc.pdispVal, L"Open", 3, parm[2], parm[1], parm[0]);
// Set pDoc = WordApp . Documents 1
parm[0].vt = VT_I4;
parm[0].lVal = 1;
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &pDoc, pWordApp.pdispVal, L"Documents", 1, parm[0]);
// Get count of words in document
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &pWords, pDoc.pdispVal, L"Words", 0);
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, pWords.pdispVal, "count", 0);
long endVali = rVal.lVal;
i.vt = VT_I4;
for(i.lVal=1; i.lVal<=endVali; i.lVal++) {
VariantCopy(&parm[1], &i);
parm[0].vt = VT_I4;
parm[0].lVal = 1;
AutoWrap(DISPATCH_PROPERTYGET|DISPATCH_METHOD, &rVal, pDoc.pdispVal, L"Words", 1, parm[0]);
wcstombs_s(0, buf, 5, rVal.bstrVal, 512);
::MessageBoxA(NULL, buf, "Word ", 0x10000);
VariantClear(&rVal);
}
}
AutoWrap(DISPATCH_METHOD, NULL, pDoc.pdispVal, L"Close", 0);
AutoWrap(DISPATCH_METHOD, NULL, pWordApp.pdispVal, L"Quit", 0);
// Close the OLE Library...
OleUninitialize();
}
Can someone help debug this code or at least tell me where I can find documentation that show the hierarchy of calls/strings to pass in order to get the information needed from the Word2003 document? Thanks in advance for your help!
wtg3
|
|
|
|
|
I have an ActiveX control for embeding in web page with opbject tag.
Now two problems:
1. I want to load data from internet location(like http://myserver/data.txt) from within ActiveX.
2. Get an IStream object of the data stream
Thanks
|
|
|
|
|
Try to use IBindStatusCallback interface.
|
|
|
|
|
Hai all
I'm using the active desktop Interface to get the current destop item count using the function GetDesktopItemCount(&count,0);
But on my desktop there is more than 10 things and the count value got by GetDesktopItemCount() is '1'.Why is it so.
Please reply.
My OS is XP.
Thanks in Advance
Robs
|
|
|
|
|
The scenario I have is, I have a COM+ application configured with a Role name "Users". I have added "BUILTIN\Administrators" and "myuser" to role "Users". User "myuser" is not a member of "BUILTIN\Administrators".
Now If the application runs under currently logged-in user, IsUserInRole() retuns true for user "myuser".
If the application is running under "myuser", then IsUserInRole() returns false for user "myuser", however if I remove "BUILTIN\Administrators" from role "Users" then IsUserInRole() returns true for user "myuser".
Could anybody please explain this behaviour of IsUserInRole()?
Thanks in advance
Cheers,
Suresh
|
|
|
|
|
Hello,
I'd like to know if it's possible for a JavaScript executed by the browser to send information to a browser helper object (BHO) also running in this browser?
The reason is that I'd like to store the login information (the login functionality is implemented in JavaScript) in my BHO instead of a cookie.
Is something like that possible? By the way, a server-side session based solution is not possible in my case.
Thanks,
Constantin
|
|
|
|
|
|
Use QueryInterface to discover whether the class implements IProvideClassInfo . From there you can discover the type information of the class.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Thanks, but not all objects implement this interface. I need reliable method wich will be suitable for all objects!
ISQ 469907496
|
|
|
|
|
vippavlo wrote: Thanks, but not all objects implement this interface. I need reliable method wich will be suitable for all objects!
You cannot do that!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Why do you need this functionality? If you can share the problem you are trying to solve, folks here can possibly tell you a better solution.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
it's very long story...
i want to save progID in XMLDOM attribute when i have only pointer to interface and than create object using this progid from XMLDOM file.
ISQ 469907496
|
|
|
|
|
vippavlo wrote: it's very long story...
I'll leave it for tomorrow, heading home in few minutes
vippavlo wrote: i want to save progID in XMLDOM attribute when i have only pointer to interface and than create object using this progid from XMLDOM file.
What about COM DLLs that support only DispInterface?
Is this so called pointer passed to you by external application or it's created in your own application?
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
/*What about COM DLLs that support only DispInterface? */
What you mean??
ISQ 469907496
|
|
|
|
|
|
It's you sorry me, maybe i said somthing wrong? because i dont know english perfect - my grammar is bad
I'm know perfect what is mean "IDispatch" ))) I don't understand your question, what you whant to tolk with this words about DDL's - what's problem with DDL's??????
I was not read you last sentence sory ....
It's a component for SDK - it save program settings to XML file and one of parameters can to be an interface and i put into XML properties of this object and want to put ProgID for in future create object using this ProgID.
Now i have this code and it work without some p'roblems, but if some other compiler, VisualBasic for example, generate type lib with another way.... it will not be working.....
Where m_spObj - its smart pointer CCOmPtr, for example...
CComPtr<itypeinfo> spTypeInfo;
UINT uiCount = 0;
GUID guidOfInterface;
hr = m_spObj->GetTypeInfo( 100, LOCALE_SYSTEM_DEFAULT, &spTypeInfo );
TYPEATTR *pattr1 = NULL;
hr = spTypeInfo->GetTypeAttr( &pattr1 );
guidOfInterface = pattr1->guid;
CComPtr< ITypeLib > spTypeLib;
hr = spTypeInfo->GetContainingTypeLib( &spTypeLib, &uiCount );
uiCount = spTypeLib->GetTypeInfoCount();
CLSID clsidOfCoclass;
for( UINT i = 0; i < uiCount; i++ )
{
CComPtr< ITypeInfo > spTI;
hr = spTypeLib->GetTypeInfo( i, &spTI );
TYPEATTR *pattr = NULL;
hr = spTI->GetTypeAttr( &pattr );
if( pattr->typekind == TKIND_COCLASS )
{
clsidOfCoclass = pattr->guid;
}
if( pattr->typekind == TKIND_DISPATCH )
{
if( guidOfInterface == pattr->guid )
{
CComBSTR bsCLSID;
ProgIDFromCLSID( clsidOfCoclass, &bsCLSID );
m_bsProgIDName = bsCLSID.Detach();
spTI.Release();
spTypeLib.Release();
spTypeInfo.Release();
return S_OK;
}
}
spTI.Release();
}
spTypeLib.Release();
spTypeInfo.Release();
return hr;
ISQ 469907496
|
|
|
|
|
vippavlo wrote: It's a component for SDK - it save program settings to XML file and one of parameters can to be an interface and i put into XML properties of this object and want to put ProgID for in future create object using this ProgID.
Now i have this code and it work without some p'roblems, but if some other compiler, VisualBasic for example, generate type lib with another way.... it will not be working.....
I think you should be allowed to insist that such objects support an appropriate IPersist interface. I recall that the plain IPersist interface has just one method which returns the class ID.
The reason that you can't use the type info for this is because there can be any number of COCLASSes in the type library that implement the interface. There is no provision for doing what you want in that case.
Nathan
|
|
|
|
|
Hi All
I need to know how i can to have the all id controls (HTML Controls) in the Page by using javascript
how can help me
thanks for any body help me
Thaer
|
|
|
|
|
Please do not cross post. Choose appropriate forum.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Dear All
I need to make an ocx to be container to RICHTX32.OCX special using VB 6 or Vb.net
text prop
DataSource Prop
DataField Prop
any tips for that ?????
thanks
bye
|
|
|
|
|
I'm trying to do some Powerpoint automation from an ASP.NET page and generate/modify a slide. That piece of the code works fine but when it's all done running and even after I call the Quit() method on the powerpoint application object, POWERPOINT.EXE remains running and eventually this is causing problems. I've googled this extensively and nothing I've found has seemed to help. I really need this to work properly.
Here's my relevant code. I don't believe i'm using any Global references and I've even removed the COM reference from my website to use Late Binding instead in hopes that it would solve my problems as mentioned in this MSDN Article: http://support.microsoft.com/default.aspx?scid=kb;en-us;319832
Code:
Public Function GenerateDrillDown(ByVal strFileName As String) As Boolean<br />
Dim App As Object = Nothing<br />
Dim pres As Object = Nothing<br />
Dim slide As Object = Nothing<br />
<br />
Try<br />
App = CreateObject("PowerPoint.Application")<br />
App.Visible = -1 ' For debugging. Comment this out or set to 0 to keep the application from being visible.<br />
<br />
pres = App.Presentations.Open("C:\DevProjects\Docs\DrillDown.ppt", 0, -1, -1)<br />
slide = pres.Slides(1) ' There's only one slide in this ppt i'm using as the template.<br />
<br />
slide.Shapes.Item("Text Box 8").TextFrame.TextRange.Text = DecisionTitle ' These are all string variables<br />
slide.Shapes.Item("Text Box 13").TextFrame.TextRange.Text = Narrative<br />
slide.Shapes.Item("Text Box 14").TextFrame.TextRange.Text = Issues<br />
slide.Shapes.Item("Text Box 19").TextFrame.TextRange.Text = Scope<br />
<br />
If TopicType = 1 Then<br />
slide.Shapes.Item("Autoshape 9").TextFrame.TextRange.Text = IDNumber.ToString()<br />
slide.Shapes.Item("Autoshape 9").Visible = -1<br />
slide.Shapes.Item("Autoshape 56").Visible = 0<br />
ElseIf TopicType = 2 Then<br />
slide.Shapes.Item("Autoshape 56").TextFrame.TextRange.Text = "ST" & IDNumber.ToString()<br />
slide.Shapes.Item("Autoshape 56").Visible = -1<br />
slide.Shapes.Item("Autoshape 9").Visible = 0<br />
End If<br />
<br />
pres.SaveAs(strFilename, 1, 0)<br />
Catch ex As Exception<br />
Return False<br />
Finally<br />
' Most of this is coming from another article I found online to help combat the problem of open references with office automation.<br />
GC.Collect()<br />
GC.WaitForPendingFinalizers()<br />
GC.Collect() ' Intentionally repeated<br />
GC.WaitForPendingFinalizers() <br />
If Not slide Is Nothing Then<br />
Marshal.FinalReleaseComObject(slide)<br />
slide = Nothing<br />
End If<br />
<br />
If Not pres Is Nothing Then<br />
pres.Close()<br />
Masrhal.FinalReleaseComObject(pres)<br />
pres = Nothing<br />
End If<br />
<br />
If Not App Is Nothing Then<br />
App.Quit() ' This doesn't do anything, no errors but ap stays open<br />
Marshal.FInalReleaseComObject(App)<br />
App = Nothing<br />
End If<br />
End Try<br />
<br />
Return True<br />
End Function
Please give me some guidance as this is an important piece of functionality required by my project. Thanks!
|
|
|
|
|
Hi,
I have a problem with pinvoke in c# trying to create a VST host.
A VST host is a little program able to use a dll which is actually
an audio effect applicable on a wave file. The dll exports only
one function : main. When you call this function it returns a
pointer to a structure that lists the capabilities of the
particular audio effect.
My problem is that whatever I try, I just can't get the pointer
that the dll is returning. I know that the call works because
I supply a Delegate to the function which in turns calls the function
in my program.
Is there anyone out there who has tried something similar or who
is a master of Interop who can help me on this topic?
Jean
|
|
|
|
|
A couple of months ago I wrote an application that acts as a host for the Cakewalk DXi Audio Plug In. The source is entirely different from the VST, but the Plug In concept is similar. Both the VST and the DXi are written as unmanaged COM Dlls (you know this, obviously). So, naturally, writing a host is alot easier in an unmanaged language.
The easiest approach is to convert your VST Plug In to a NET assembly by using the Type Library Import Utility (tlbimp.exe[^]) shipped with SDK. This creates an assembly that you can then reference and use directly with your host application.
A better approach would be to write your host in Unmanaged C++; sometimes the function types generated by the Type Library Import Utility are just too cumbersome to use easily.
You might read this: Importing a Type Library as an Assembly[^]. I'm assuming that the VST DLL contains a type library. If not, you'll have to write your audio host in unmanaged C++ (unless you want to write your own Runtime Callable Wrappers, which is a very tedious and error-prone process; if you are a novice at Interop, I wouldn't recomment it).
Good Luck.
-- modified at 17:18 Thursday 25th October, 2007
|
|
|
|
|
http://vstnet.codeplex.com
VST.NET allows you to write a VST host in managed code (C#/VB.NET). Check out the Host sample that is available. VST.NET will take care of all the marshaling between unmanaged and managed code so you do not need to call P/Invoke's. Note that VST.NET only supports VST 2.4.
VST.NET also supports writing VST plugins.
|
|
|
|
|
while registering registry i am getting it is succeded but when i am going to search the CLSID of the same it doesnt gives...whats wrong here???
shailesh
|
|
|
|
|