Click here to Skip to main content
15,916,180 members
Home / Discussions / COM
   

COM

 
GeneralGetting selected folder in a namespace extension Pin
Mike Hartway25-Jul-03 14:28
Mike Hartway25-Jul-03 14:28 
QuestionHow to SendMessage to a windowless Ctrl Pin
ray_li25-Jul-03 5:41
ray_li25-Jul-03 5:41 
AnswerRe: How to SendMessage to a windowless Ctrl Pin
John M. Drescher25-Jul-03 6:54
John M. Drescher25-Jul-03 6:54 
AnswerRe: How to SendMessage to a windowless Ctrl Pin
MartinOrtiz31-Jul-03 12:24
MartinOrtiz31-Jul-03 12:24 
GeneralCOM+ / MSMQ Pin
sam_jr24-Jul-03 17:05
sam_jr24-Jul-03 17:05 
GeneralRe: COM+ / MSMQ Pin
ICBM25-Jul-03 15:02
ICBM25-Jul-03 15:02 
GeneralClosing document in Word under Automation Pin
Dave Loeser24-Jul-03 4:52
Dave Loeser24-Jul-03 4:52 
Generalword automation Pin
Jason Henderson23-Jul-03 10:06
Jason Henderson23-Jul-03 10:06 
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>
	// get storage for the object via virtual function call
	m_dwItemNumber = GetNewItemNumber();
	GetItemStorage();
<br> <br>
	// add AfxOleInit(); in CXOfficeApp::InitInstance
	AfxOleGetMessageFilter()->EnableNotRespondingDialog(FALSE);
<br> <br>
	// attempt to create the object
	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(""));  // trying to set the password
				doc->Password = L"";  // this doesn't work either
<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.


GeneralArrays of IUnknown.. Pin
ICBM22-Jul-03 0:27
ICBM22-Jul-03 0:27 
GeneralRe: Arrays of IUnknown.. Pin
valikac22-Jul-03 8:56
valikac22-Jul-03 8:56 
GeneralRe: Arrays of IUnknown.. Pin
first_sandy25-Jul-03 3:40
first_sandy25-Jul-03 3:40 
GeneralRe: Arrays of IUnknown.. Pin
ICBM25-Jul-03 13:44
ICBM25-Jul-03 13:44 
QuestionHow to prevent binding a Type library to a ATL Attributed DLL ? Pin
talhalfon21-Jul-03 22:39
talhalfon21-Jul-03 22:39 
GeneralIE plugin Pin
nettrinity20-Jul-03 17:04
nettrinity20-Jul-03 17:04 
GeneralRe: IE plugin Pin
ashxly21-Jul-03 18:41
ashxly21-Jul-03 18:41 
GeneralRe: IE plugin Pin
nettrinity21-Jul-03 21:35
nettrinity21-Jul-03 21:35 
GeneralRe: IE plugin Pin
ashxly21-Jul-03 18:41
ashxly21-Jul-03 18:41 
GeneralOCX issue Pin
carb18-Jul-03 9:58
carb18-Jul-03 9:58 
GeneralGetting an Explorer history item URL Pin
yarp18-Jul-03 0:06
yarp18-Jul-03 0:06 
GeneralCOM Support in new Windows OS Pin
Paul Roullier17-Jul-03 2:58
Paul Roullier17-Jul-03 2:58 
GeneralRe: COM Support in new Windows OS Pin
Michael P Butler22-Jul-03 4:38
Michael P Butler22-Jul-03 4:38 
GeneralDisplay name of components Pin
first_sandy16-Jul-03 21:14
first_sandy16-Jul-03 21:14 
GeneralRe: Display name of components Pin
Vi216-Jul-03 21:23
Vi216-Jul-03 21:23 
GeneralRe: Display name of components Pin
first_sandy16-Jul-03 22:27
first_sandy16-Jul-03 22:27 
GeneralRe: Display name of components Pin
Vi216-Jul-03 22:52
Vi216-Jul-03 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.