|
How can I take an instantiated Word document object and open it in a container item? I'm using COleClientItem::CreateFromFile, but if the document has a password it opens the word application, and I don't want that to happen.
So, I'd like to take my Word::_DocumentPtr that is already open and move it into my container item. Any ideas?
If that's not possible, how should I open the document without the password? I have tried opening it using Word.Application and then setting the password and saving, but the password doesn't seem to be set to "" when I open it again. Here's what I'm doing now:
BOOL CDocContainerCntrItem::Create(LPCTSTR lpszPath)
{
USES_CONVERSION;
<br> <br>
BOOL bRetVal = FALSE;
SCODE sc = 0;
<br> <br>
m_dwItemNumber = GetNewItemNumber();
GetItemStorage();
<br> <br>
AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE);
<br> <br>
LPOLECLIENTSITE lpClientSite = GetClientSite();
<br> <br>
if (strcmp(lpszPath, "") != 0)
{
Word::_ApplicationPtr app;
HRESULT hr = app.CreateInstance("Word.Application");
<br> <br>
if (SUCCEEDED(hr))
{
if (app != 0)
{
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant vtFileToOpen(lpszPath);
COleVariant vtPwd("MYPASS");
COleVariant vtPwdNew("");
<br> <br>
Word::_DocumentPtr doc = app->Documents->Open(vtFileToOpen, vtOptional,
vtOptional, vtOptional, vtPwd);
<br> <br>
doc->put_Password(_bstr_t(""));
doc->Password = L"";
<br> <br>
if (SUCCEEDED(doc->SaveAs(vtFileToOpen, vtOptional, vtOptional, vtPwdNew)))
{
doc->put_Saved(VARIANT_TRUE);
doc->Close();
}
doc = NULL;
<br> <br>
bRetVal = CreateFromFile(lpszPath);
}
}
<br> <br>
app = NULL;
}
else
{
CLSID clsid;
CLSIDFromProgID(L"Word.Document", &clsid);
bRetVal = CreateNewItem(clsid);
}
<br> <br>
return bRetVal;
}
Any help is greatly appreciated!
Jason Henderson I bleed orange.
|
|
|
|
|
Hello all
What I am trying to do is implement a function in an ATL COM server that returns an array of objects. I need to be able to use these objects from VB. My searches on the net turned up lots of references to using SAFEARRAY(VARIANT), but very little sample code. Ideally, I'd love a link to some code that declares a method like
GetObjects([in,out] SAFEARRAY(VARIANT) *ppObjects)
and shows both the implementation in C++ (including creating and populating the SAFEARRAY with IUnknown-derived object pointers) and some calling code, either in VB or C#.
Thanks all
Ian
|
|
|
|
|
There are some good examples here at CodeProject. Look under the beginner section.
http://www.codeproject.com/com/
Kuphryn
|
|
|
|
|
Hi Ian,
You can create a safe array of variants and then put the array in the variant and pass to the client.
Like :
SAFEARRAY *pSA =NULL;
SAFEARRAYBOUND sabound;
sabound.cElements = nCount; //Array size.
sabound.lLbound = 0;
pSA = SafeArrayCreate(VT_VARIANT, 1, sabound);
long nIterator = 0;
//in a loop put the values.
hr = SafeArrayPutElement(pSA, nIterator, (void *)&vaPutValue);
VARIANT vaResult;
VariantInit(&vaResult);
V_VT(&vaResult) = VT_ARRAY | VT_VARIANT;
V_ARRAY(&vaResult) = pSA;
return vaResult;
At client side, you can write it like:
Dim vaDocList as Variant
vaDocList = m_pClass.GetArray() 'm_pClass is the reference to co-class.
get bounds like
nUBound = UBound(vaDocList)
nLBound = LBound(vaDocList)
in a loop get values in the variables as per ur requirement.
i feel it will help you.
sandy
Last night i realized, i was seeing a dream in my dream.
|
|
|
|
|
Thanks very much for that, just what I was after
|
|
|
|
|
How to prevent binding a Type library to a ATL Attributed DLL ?
need help
ty
tal halfon
|
|
|
|
|
I want to write a Internet Explorer embeded Text editor for a government document transfer system. I want it embed in to IE, just like those online virus scan...ETC. when you first use it, a dialog box popup asking you whether or not the program is allowed to run. I bet it was probably a activeX control (ocx)?, right?(curret me, I am wrong )
but I don't know how. It must ba a lot different from writing win32 application.(i am new to ie plugin )
can anybody tell me where I can find some documents regarding this?
And is it a really a activeX control?
even a link or a book name will help!
thanks in advance!
xushenxin
keep fighting and you will win!
|
|
|
|
|
try to use atl com, create a internet browse object
for more detail ,plz check the msdn.
|
|
|
|
|
OK ,I'll check it out, thanks!: )
xushenxin
keep fighting and you will win!
|
|
|
|
|
try to use atl com, create an internet browse object
for more detail ,plz check the msdn.
|
|
|
|
|
Hello:
My first post so apologies if I've put this in the wrong place or broken some (n)etiquette.
I'm using a grid control .ocx file from inside an MFC app; all C++, built under VC++ 6.0. It has worked fine since
1999 but now is starting to cause problems on Win2000 machines (shows up in all service packs). The identical code works fine under Win98, so I'm guessing it's an upgrade issue.
All the dialogs I try to launch via the ocx fail with the following error message in Visual C++ 6.0 (cut and pasted from the Debug window):
CoCreateInstance of OLE control {A8C3B720-0B5A-101B-B22E-00AA0037B2FC}
failed.
>>> Result code: 0x80040154
>>> Is the control is properly registered?
Warning: CreateDlgControls failed during dialog init.
The control is registered properly via regsvr32 before running the app.
The above error message appears on the call to:
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
in CWnd::CreateDlgIndirect(), called from CDialog::DoModal() in the usual way.
The behavior seen in release versions is that no dialog appears in response to user action (menu choice, etc).
I know next to nothing about COM/ActiveX/OLE objects, so if there's either a quick fix, or an explanation why this would happen (so I can stop the wild goose chase), I'd appreciate it.
The original supplier of this commercial ocx can't supply an update.
I hope this is enough info; it's all I can share.
Thanks,
-Chuck.
C J Charbonneau
Ottawa, Canada
|
|
|
|
|
I'm implementing a web navigator application and I'm currently working on the history items. Does anybody know how I can get the URL pointed to starting from the item pidl ?
Thanks in advance,
Yarp
http://www.senosoft.com/
|
|
|
|
|
Does anyone have any idea how long COM/VB6(classic) will be supported. Will .Net dump COM in the next generations of operating systems.
Paul Roullier
Senior Developer
|
|
|
|
|
Whilst there is still a Win32 API there will be COM support. COM is used in too many legacy systems for Microsoft to pull support. Backwards compatability has only been one of MS's greatest strengths.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Hi,
Can any one help me how to change the display name of components.
Like in ODL file, the syntax is:
[uuid(.......), version(1.0)]
library MyComponentLibrary
{
.......
In this case the display name of my component is "MyComponentLibrary" but i want to change it to
"iZ imaging Toolkit 2004 R1.0".
Please reply me soon if you have any suggestions.
rgds,
Rana
Dosti ke bhi kuch andaaj hote hai,
jagti ankho main bhi kuch khwab hote hai,
jaroori nahi ki gum may hi aansu nikle,
muskurati ankho main bhi sailaab hote hai...
|
|
|
|
|
Use the [helpstring] keyword.
[uuid(.......), version(1.0),
helpstring("iZ imaging Toolkit 2004 R1.0")
]
library MyComponentLibrary
...
With best wishes,
Vita
|
|
|
|
|
Thanks Victor,
But it does not work.
When i register my component, its display name is still "MyComponentLibrary".
pls put ur comment ..
rgds,
Rana
|
|
|
|
|
So what is your "display name"?
Dim obj As MyComponentLibrary.SomeObjectFromLib ?
Or the title in some Dialogs "[ ] MyComponentLibrary" ?
As far COM, the "library MyComponentLibrary" gives the name of library. It cannot be changed, but only by new name.
With best wishes,
Vita
|
|
|
|
|
Like in Visual basic,
Open the menu Project->References.
In References dialog box the Display names of components are different than their library names.
I just want to know how can i change that name in the References dialog box.
rgds,
rana
|
|
|
|
|
With [helpstring] of the library statement of IDL(ODL). When I make such change, I will see it in VB project.
Hm... I see that the VB saves the name in own project. It needs for the showing of missing references. Though the VB rechanges these names before saving or opening the project.
With best wishes,
Vita
|
|
|
|
|
Hi,
What Victor mentioned is correct. Modifying the helpstring in IDL/ODL, will reflect in the tlb listing dlg. If you are not getting it, might be somthiing else is wrong.
best wishes..mil10
|
|
|
|
|
Does anyone have a small C++ example on how to use the Image Mastering API (IMAPI) in Windows XP?
In what file does the type library appear in? There is an executable called imapi.exe in the System32 directory but it does not contain the type library.
Regards
Martin
|
|
|
|
|
Hi,
When I use the following code to create an instance of Internet Explorer, the top window seems to lose focus.
HWND hForegroundWindow = GetForegroundWindow();
CLSIDFromProgID(OLESTR("InternetExplorer.Application"), &clsid);
CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IUnknown, (LPVOID*)&pUnk);
pUnk->QueryInterface(IID_IWebBrowser2, (LPVOID*)&pWB);
pUnk->Release();
SetForegroundWindow(hForegroundWindow);
When CoCreateInstance function is called, the top window loses it focus, and invisible IE seems to receive the focus.
I get the handle to the foreground window and set it back after CoCreateInstance is called. However, i still do lose focus in that couple seconds. This is particularly annonying when i am tying something. Because when the top window loses its focus, the input will stop. Is there anyway to make it so that when CoCreateInstance is called, the foreground will still keep the focus?
Thanks
|
|
|
|
|
Hey everyone...
I have been trying to find some documentation on how to access contact (name, e-mail, phone, anniversary, etc.) info within Outlook Express. I am currently able to get at data using a typelib for Outlook 2000 and XP, but alas, it doesn't work with Outlook Express.
Does anyone know if there is a typelib avaialble, or if there is some documentation somewhere that would help me get started?
Thanks...
Brigg Thorp
Software Engineer
Timex Corporation
|
|
|
|
|
Hello Brigg,
Well, you are certainly asking in the right forum. I'm assuming you know COM programming. you would need it to use my sdk.
What you are looking to do with Outlook Express is possible through 'undocumented' means. Please checkout my messageboard here. I'm working on a future CP article on this, but as of now, it's not meant for public distrib.
Cheers,
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - Writing Word addins
Office addin
|
|
|
|
|