DSOFramer 1.3
The DSOFramer VC++ Control is released provided by Microsoft to demonstrate how to host Office documents in VB or HTML. As a COM component, it can also be invoked inside .net applications. Unfortunately MS does NOT guarantee any support as it is provided as an example only.
Previously I wrote an article mostly on DSOFramer version 1.2, and now it’s time to talk about version 1.3. I will focus on embedding office documents inside WinForm issues, but not web usage such as uploading or remote calling.
Overview
For basic concept, I suggest you read the knowledge base article first (See Reference).
The new version solves most of the problems I mentioned last time, yet bring some new ones. Briefly, It now supports Office 2007 documents; Provides several options for parent window hooking and focus/activation policies; Custom error messages; And much more.
Shortcoming / Workaround
- When DSOFramer is wrapped in an user control, problem appears when the control is used as multiple instance, i.e.: TabbedPage.
- Can not use more than 10 instances per process
To reproduce this bug, use the sample VB application in the download package (${ExtractDir}\Samples\Vb7Test\VB7TestApp.exe). Create several new documents with same type, for example, excel files. After switching between the tab pages several times, the toolbar in the first opened window turned to be weird.
Workaround:
In your custom user control, set the following properties of the AxFramerControl: Activationpolicy=dsoIPDeactivateOnCompDeactive, FrameHookPolicy=dsoSetOnFirstOpen. But this leads to another problem: the inner office application is reloaded everytime the control is activated. So if you wanna hide some of the toolbar buttons, you have to use the code in the activation blocks instead of the control initialize statement.
The error message cound be “Unable to set frame hook for the parent window.” or “Error HRESULT E_FAIL has been returned from a call to a COM component.” depending on different policy setting.
Workaround:
Actually this is not a bug, but the way this OCX acts. To overcome this limit, you have to modify the source code and recompile(see the notice in my last article) the OCX and then register it again. Open “${ExtractDir}\Source\dsoframer.h”, Find this line:
modify the number as you wish, but for best performance purpose I don’t recommend a number larger than 20.
I will continue to update this section as research going deeper.
Download
I made a sample project to use this control as a demo, download and try it if you are interested: DSOFramerDemo
Reference
KB: http://support.microsoft.com/kb/311765/
Download Link: http://www.microsoft.com/downloads/details.aspx?FamilyId=CE2CA4FD-2169-4FAC-82AF-770AA9B60D77&displaylang=en
Hi,the control can run mutil-instance only in one thread.can not run mutil-thread.
August 8th, 2007 at 11:12 amHi, stephen:
I haven’t tested it in multi-thread environment, but according to the code comments, it should be able to do that.
August 16th, 2007 at 11:14 amHi,
October 15th, 2007 at 4:26 pmi use DSOFramer embeded in a web site.
i work with Webdav on tomcat and i want to open and save office documets from and to the server via webdav.
with powerpoint there’s no problem , however with word and excel i get this wierd error message : “The process cannot access the file because it is being used by another process.
can you give me a hint ?
Did you happened to register some events to the word/excel process?
As far as I know, this ocx control might have some bugs with the event handle, which may lead to a dead lock. The ocx container will throw the above-mentioned message if it fails to get response from the ocx after a certain time.
F.Y.I: I encountered this problem in .NET(C#)
October 15th, 2007 at 7:54 pmI haven’t register any events on the process (I even don’t know how to do it
My code works fine for PPT but gives the error I mentioned above for DOC or XLS. (what could be the reason for that?)
Attached a snippet of my HTML page:
openOfficeDoc = function() {
oframe.open(”http://localhost/webdav/SomeFile.doc”,false);
}
saveOfficeDoc = function() {
oframe.save(”http://localhost/webdav/SomeFile.doc”,true);
}
Thanks in advance for any help or suggestion, Ori.
October 15th, 2007 at 9:17 pmA MS-Office process will be started internally when the control’s initialize method is being called and there’s no existing one, or the ocx will try to attach itself to the existing one(actually the most-first opened) if there’s any.
In our situation, we found that if the control is not properly shut down, there will be miscellaneous problems afterwards. So we double check the process and kill any existing one to minimize this side-effect. You can also check to see if the word/excel process is still alive on the server when the problem occurs.
I’m not familiar with the WebDAV thus can’t help much on this. the code snippet you attached seems to be a javascript function, and I think the open method has some more parameters which might lead to different results (but haven’t tried to much as I use it mostly on client instead of the web).
Finally you can goto this forum, guys there talked about this control a lot (all in Chinese, you might need google translate :p):
http://www.dsoframer.com/forumdisplay.php?fid=2
October 16th, 2007 at 9:19 amHi Cube
Thanks for your brilliant example. It seems to have the same bug as mine. Have you tried the following:
- Open a word document in the control.
- Open Word like you normally do, and close it again
The word-toolbar inside the control is now dead…
Any ideas?
Pulling my hair out here…
Regards
Uffe
January 11th, 2008 at 10:23 pmHi, Uffe:
Any chance to change the “Activationpolicy” and/or “FrameHookPolicy” parameter?
January 14th, 2008 at 2:42 pmHi Cube
Tried that…no success
Can you reproduce the bug?
January 15th, 2008 at 4:53 pmWell, I tried my above-mentioned demo application: download, it works fine on my machine(windows xp, office2003).
Although the example uses excel as an example, I think it is identical with MS word.
You can have a try with the binary file I provided inside, and then modify the source code to start word instead later on.
Pay attention to the two parameters I mentioned above, as the bug is gone here when I set them properly.
January 18th, 2008 at 9:37 amHello guys, i have following problem with DSOFramer..
I open/create excel book in DSOFramer, but cannot properly close it, because the file still beeing “oppened” and other processes? except reall excel application, cant get access to it.
The Code:
public virtual void OpenExisting(string path, bool readOnly)
{
try
{
//todo need to add HTTPDownloader, because COM doesnt show server exceptions
framerControl.Open(path, readOnly, EXCEL_APP_NAME, string.Empty, string.Empty);
}
catch (COMException ce)
{
framerControl.Close();
log.Error(ce);
ExceptionBox.Show(ce);
}
}
public void CloseDocument()
{
object activeObject = this.framerControl.ActiveDocument;
if (activeObject != null)
{
xlBook = null;
xlApplication.Quit();
int counter;
counter = Marshal.ReleaseComObject(xlApplication);
xlApplication = null;
}
xlBook = null;
xlApplication = null;
xlSheets = null;
framerControl.Close();
}
Any suggestion welcomed:)
January 19th, 2008 at 1:17 amP.S. sorry for my bad english
Hi,Zond:
try to release all the COM object from the lower level to the higher level (that is: xlSheet, xlBook, xlApplication, etc…).
it is also a good idea to call the C# GC method to release all the resources.
Anyway, this control is NOT stable enough for product usage.
January 22nd, 2008 at 10:20 amHi.
January 30th, 2008 at 5:17 amCan someone help me with this ctrl. I want to save file in different format. How can I do it. And also I want to ask about some properties FrameHookPolicy and ActivationPolicy what is for. Thank you.
Hi, Oleg:
In which format do you want the documents to be saved as exactly?
and, the description for the two properties(as well as the others) could be easily found in the source code, Microsoft has released the source code together with the control itself.
February 2nd, 2008 at 1:54 pmI want to save file in xml worsheet for example.
February 2nd, 2008 at 4:13 pmAs far as I know, this control does not support office2007, so it might be a bit difficult to get it worked on that.
February 2nd, 2008 at 8:16 pmcube316 at list this ctrl works with Office 2007
February 3rd, 2008 at 1:09 amI cannot seem to get Dsoframer to open Word documents read-only. I use
February 3rd, 2008 at 6:24 amchDsoFramer.framercontrol.open(c:\testdoc.doc,true,”word.document”,,)
but then if I try and access the same document using the same code on a different machine I get the message ‘document is locked for editting’. I don’t want to edit the document, I want to open it read-only !
Hi Uffe,
i am having the exact same problem as urz… i tried debuging the ugly c++ source code…. playing with the “Activationpolicy” and/or “FrameHookPolicy” parameters… but no success..
i really appreciate it if you could tell me what have u done.. any progress??
May 5th, 2008 at 8:28 pmHi Arij
I have not been able to solve the problem yet.
Let me know if you succeeds
Regards Uffe
May 6th, 2008 at 3:28 pmHi guys:
I’ve checked the page on microsoft website and it turned out to be no news. In addition, my work related to this control in the company has been ended up.
As a result, I’m afraid I will not put too much energy on this as usual. But I will continue to update this post once something useful come out.
Sorry I didn’t help you too much on your problems.
May 6th, 2008 at 4:12 pmHello,
May 15th, 2008 at 4:27 amI need to know how to hide all toolbars. Whenever I programmatically hide the toolbars the dsoframer still shows a space where if you right-click then you can chose to show any toolbars.
How can I avoid this space to appear? Do you know?
Thanks a lot for any help
hi, martin bevil:
This problem does exist, I have found it from the very beginning.
In principle, the DSOFramer control embedded MS office in your application, while the inner behavior still belongs to office application(word, excel, etc) itself, hence the popup menu is always available on right click.
Maybe one have to dive into the control code to completely disable the popup menu, but that’s far beyond my current ability(I’m not a c++ programmer, you know :))
May 15th, 2008 at 9:33 amHi,
could anybody send me an asp.net code example? How can I call dsoframe object via vb.net code?
I would like to open am excel file which will be filled by an sql server.
thanks in advance
July 8th, 2008 at 12:16 amThe following are sent by cube on behalf of Martin:
================================================
(To LandroHun and anyone interested)
Hi,
I can send you my code using dsoframer to merge data from sqlserver, the documento itself and header/footer, also manage print settings programmatically.
It’s an ASP page. I put all the processing at client side then user can print or save the result document to database or whatever. I send the processing to client to not open thousands of processes to the server.
In your solution I think you should open/create excel doc, put all yuor sql info to vbscript (as I do in ASP page), then programmaticaly (using VBA languaje) do whatever in the excel file and then send the document back to sqlserver, to the user, printing, whatever you need.
I’m in a middle of a job. Later I’ll send you some code. It may help you.
Download the code here
July 10th, 2008 at 1:12 pm