mmx110 Posted May 17, 2016 Posted May 17, 2016 Edraw Office Viewer Component contains a standard ActiveX control that acts as an ActiveX document container for hosting Office documents. there is a sample of How to Use it with HTML Files: https://www.edrawsoft.com/embed-word-html.php 1-How to Integrate Office Viewer Component with Unigui via UniHTMLFrame ? 2- How to Pass Params to Object Or recieve Params from Object? Thanks and Regards Quote
mmx110 Posted May 18, 2016 Author Posted May 18, 2016 Hi Forum unfortunately There is not Response to My question yet... I can load an ActiveX Object to UniHTMLFrame but How we can Pass Parameter or Receive Response from an Objects? for example sending Unibutton OnClick event to the Object inside the HtmlFrame or Receive Parameter From Object I want to Work with Event of an ActiveX Object as in Coding space in delphi... Best Regards Quote
bugra Posted May 18, 2016 Posted May 18, 2016 Hi You can use javascript like procedure TUniForm3.UniButton1Click(Sender: TObject); var sendParam: string; begin sendParam := 'myParam'; UniSession.AddJS('document.getElementsByName("Toolbars")[0].value ="'+sendParam+'";'); end; Quote
mmx110 Posted May 18, 2016 Author Posted May 18, 2016 Thanks Bugra For your Response! But how about an object inside UniHtmlFrame, How can set or read Properties from object inside it Ragards Quote
bugra Posted May 18, 2016 Posted May 18, 2016 Theese code also find object inside UniHTMLFrame, but if you wanna find specific object try this one procedure TMainForm.UniButton1Click(Sender: TObject); var sendParam: string; begin sendParam := 'myParam'; UniSession.AddJS( 'var c = document.getElementById("OA1");'+ 'var childo = c.children;'+ 'var j;'+ 'for (j = 0; j < childo.length; j++)' + '{' + 'if (childo[j].tagName == "PARAM" && childo[j].name=="Toolbars")' + '{'+ 'childo[j].value = "'+sendParam+'";' + '}' + '}') ; end; Quote
mmx110 Posted May 18, 2016 Author Posted May 18, 2016 Thank You very much Bugra! at the Final please Provide a sample code that an Object inside UniHTMLFrame send feedback response to Uniedit or some other UniComponents or External Variables... Regards Quote
bugra Posted May 18, 2016 Posted May 18, 2016 for UniEdit write this code inside JavaScript MainForm.UniEdit1.setValue("your new value"); in your case you can change "your new value" into "childo[j].value" without " . other uniComponent may use setValue or use setText. Both are same usage. for more information you can look Sencha's ExtJS document http://docs.sencha.com/extjs/4.2.3/#!/api For External variables you can use ajaxRequest. just add theese lines after your JS. ajaxRequest(MainForm.UniButton1, 'newParam', ['MyParam'=myParam]); (myParam is uniHTMLFrame response) After then call this param inside UniButton1's OnAjaxEvent like this procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var someString:string; begin if EventName='newParam' then begin someString = Params.Values['MyParam']; end; end; Quote
valadi Posted June 13, 2016 Posted June 13, 2016 plz upload sample code Office Viewer Component with Unigui Quote
mmx110 Posted June 15, 2016 Author Posted June 15, 2016 Hi Forum! How to load an ActiveX in UniGHI like Edraw Office ViewerI want to use msword as editor in uniguiThanks and Regards Quote
Sherzod Posted June 15, 2016 Posted June 15, 2016 Hi, For now, I tried to display the doc, but it is works only in IE and with some "limitations" too... 1. Add the Website: https://www.edrawsoft.com in the IE Trust Site List 2. UniHTMLFrame1.HTML... <object classid="clsid:7677E74E-5831-4C9E-A2DD-9B1EF9DF2DB4" id="OA1" width="100%" height="100%" codebase="https://www.edrawsoft.com/download/officeviewer.cab#7,5,0,355"> <param name="Toolbars" value="-1"> <param name="BorderColor" value="15647136"> <param name="BorderStyle" value="2"> </object> 3. UniHTMLFrame1.AfterScript... document.all.OA1.Open("http://" + window.location.hostname + ":8077/files/uniGUI.docx", "Word.Application") Result: Best regards. Quote
mmx110 Posted June 15, 2016 Author Posted June 15, 2016 Well Done! You have a great talent! Thanks for your consideraion there is some javascript action for interaction with EDRAW ActiveX How to send this actions via UniButton onclick to it? For Example to creat new document or opening in Read only Mode Or something else... or check some parameter results from it? For Example if document changed and should be saved... Best Wishes and Warm Regards Quote
valadi Posted June 15, 2016 Posted June 15, 2016 Hi, For now, I tried to display the doc, but it is works only in IE and with some "limitations" too... 1. Add the Website: https://www.edrawsoft.com in the IE Trust Site List 2. UniHTMLFrame1.HTML... <object classid="clsid:7677E74E-5831-4C9E-A2DD-9B1EF9DF2DB4" id="OA1" width="100%" height="100%" codebase="https://www.edrawsoft.com/download/officeviewer.cab#7,5,0,355"> <param name="Toolbars" value="-1"> <param name="BorderColor" value="15647136"> <param name="BorderStyle" value="2"> </object> 3. UniHTMLFrame1.AfterScript... document.all.OA1.Open("http://" + window.location.hostname + ":8077/files/uniGUI.docx", "Word.Application") Result: UniGUI_isthebest.png Best regards. thanks how do add function in UniHTMLFrame1.HTML OR add function use unibutton <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Edraw Office Viewer Component Demo - EdrawSoft</title> <style> <!-- .Hlink {cursor: hand; text-decoration: underline; color: #0066CC; font-weight:normal;} --> </style> </head> <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript> <!-- function CreateWord() { document.all.OA1.CreateNew("Word.Application"); } function CreateExcel() { document.all.OA1.CreateNew("Excel.Application"); } function CreatePpt() { if(document.all.OA1.CreateNew("PowerPoint.Application") == false) { window.alert("Failed to create powerpoint instance. Please shut off others ms office instance in the task manager. Add the demo site in the IE Trust Site List."); } } function OpenFromLocal() { if(document.all.OA1.OpenFileDialog() == false) { window.alert("Failed to open file. Please shut off the bad ms office instances in the task manager."); } //You can call the Open method to open silently. } function OpenFromServer() { var sPath= window.prompt("Type the file url:", "http://www.ocxt.com/demo/samples/sample.doc"); document.all.OA1.Open(sPath); //document.all.OA1.Open(sPath, "Word.Application"); //document.all.OA1.Open(sPath, "Excel.Application"); //document.all.OA1.Open(sPath, "PowerPoint.Application"); //document.all.OA1.Open(sPath, "Visio.Application"); //document.all.OA1.Open(sPath, "MSProject.Application"); } function PrintDoc() { if(document.all.OA1.IsOpened()){ document.all.OA1.PrintDialog(); } } function PrintPreview() { if(document.all.OA1.IsOpened()){ document.all.OA1.PrintPreview(); } } function ProtectDoc() { if(document.all.OA1.GetCurrentProgID() != "PowerPoint.Application") { if(document.all.OA1.IsOpened()){ if(document.all.OA1.GetCurrentProgID() == "Word.Application"){ document.all.OA1.ProtectDoc(2);//wdAllowOnlyFormFields } else if(document.all.OA1.GetCurrentProgID() == "Excel.Application"){ document.all.OA1.ProtectDoc(1); } } } else { document.all.OA1.SlideShowPlay(true); } } function UnProtectDoc() { if(document.all.OA1.GetCurrentProgID() != "PowerPoint.Application") { if(document.all.OA1.IsOpened()) { document.all.OA1.UnProtectDoc(); } } else { document.all.OA1.SlideShowExit(); } } function DocIsDirty() { if(document.all.OA1.IsOpened()){ if(document.OA1.IsDirty) { window.alert("The file has been modified!"); } else{ window.alert("The file hasn't been modified!"); } } } function ShowHideToolbar() { if(document.all.OA1.IsOpened()){ var x = document.OA1.Toolbars; document.OA1.ShowMenubar(! x); document.OA1.Toolbars= ! x; } } function DisableHotKey() { if(document.all.OA1.GetCurrentProgID() == "Word.Application"){ if(document.all.OA1.IsOpened()){ document.all.OA1.WordDisableSaveHotKey(true); document.all.OA1.WordDisablePrintHotKey(true); document.all.OA1.WordDisableCopyHotKey(true); } } else if(document.all.OA1.GetCurrentProgID() == "Excel.Application") { document.all.OA1.WordDisableSaveHotKey(true); document.all.OA1.WordDisablePrintHotKey(true); document.all.OA1.WordDisableCopyHotKey(true); } else { } } function DisableRightClick() { if(document.all.OA1.IsOpened()){ document.all.OA1.DisableViewRightClickMenu(true); } } function SaveAs() { if(document.all.OA1.IsOpened()){ document.all.OA1.SaveFileDialog(); } } function SavetoServer() { if(document.OA1.IsOpened) { document.OA1.SetAppFocus(); document.OA1.HttpInit(); var sFileName = document.OA1.GetDocumentName(); document.OA1.HttpAddPostOpenedFile (sFileName); //save as the same file format with the sFileName then upload //document.OA1.HttpAddPostOpenedFile (sFileName, 16); //save as docx file then upload //document.OA1.HttpAddPostOpenedFile (sFileName, 0); //save as doc file then upload //document.OA1.HttpAddPostOpenedFile (sFileName, -4143); //save as xls file then upload //document.OA1.HttpAddPostOpenedFile (sFileName, 51); //save as xlxs file then upload document.OA1.HttpPost("http://www.ocxt.com/demo/upload_weboffice.php"); if(document.OA1.GetErrorCode() == 0 || document.OA1.GetErrorCode() == 200) { var sPath = "Save successfully! You can download it at http://www.ocxt.com/demo/"+ sFileName; window.alert(sPath); } else { window.alert("you need enable the IIS Windows Anonymous Authentication if you have not set the username and password in the HttpPost method. you need set the timeout and largefile size in the web.config file."); } } else{ window.alert("Please open a document firstly!"); } } function CloseDoc() { if(document.OA1.IsOpened) { document.all.OA1.ExitOfficeApp(); } } function VBAProgramming() { if(document.OA1.IsOpened) { if(document.all.OA1.GetCurrentProgID() == "Word.Application"){ var objWord = document.OA1.ActiveDocument;//Word _Document VBA Interface var range = objWord.Range(0,0); var WTable = objWord.Tables.Add(range, 3,3); WTable.Cell(1,1).Range.Font.Name = "Times New Roman"; WTable.Cell(1,1).Range.Text = "Automation 1"; WTable.Cell(1,2).Range.Font.Size = 18; WTable.Cell(1,2).Range.Bold = true; WTable.Cell(1,2).Range.Font.Italic = true; WTable.Cell(1,2).Range.Text = "Automation 2"; WTable.Cell(2,1).Range.ParagraphFormat.Alignment = 1; // 0= Left, 1=Center, 2=Right WTable.Cell(2,1).Range.Font.Name = "Arial"; WTable.Cell(2,1).Range.Font.Size = 12; WTable.Cell(2,1).Range.Bold = false; WTable.Cell(2,1).Range.ParagraphFormat.Alignment = 2; WTable.Cell(3,3).Range.Font.Name = "Times New Roman"; WTable.Cell(3,3).Range.Font.Size = 14; WTable.Cell(3,3).Range.Bold = true; WTable.Cell(3,3).Range.Font.Underline = true; WTable.Cell(3,3).Range.ParagraphFormat.Alignment = 0; WTable.Cell(3,2).Range.Text = "Automation 3"; } else if(document.all.OA1.GetCurrentProgID() == "Excel.Application"){ var objExcel = document.OA1.GetApplication();//Excel _Application VBA Interface var worksheet = objExcel.ActiveSheet; worksheet.cells(1,1).value ="100"; worksheet.cells(1,2).value ="101"; worksheet.cells(1,3).value ="102"; worksheet.cells(2,1).value ="103"; worksheet.cells(2,2).value ="104"; worksheet.cells(2,3).value ="105"; } else if(document.all.OA1.GetCurrentProgID() == "PowerPoint.Application"){ var ppt = document.OA1.GetApplication();//PowerPoint _Application VBA Interface var cap = ppt.Caption; window.alert(cap); } else if(document.all.OA1.GetCurrentProgID() == "Visio.Application"){ var vx = document.OA1.GetApplication();//Visio IVApplication VBA Interface var path = vx.Path; window.alert(path); } else if(document.all.OA1.GetCurrentProgID() == "MSProject.Application"){ var pj = document.OA1.GetApplication();//Project _MSProject VBA Interface var name = pj.Caption(); window.alert(name); } } } function OA1_NotifyCtrlReady() { //document.OA1.ShowRibbonTitlebar (false); //document.OA1.ShowMenubar (false); //document.OA1.Toolbars = false; //If you want to open a document when the page loads, you should put the code here. //document.all.OA1.Open("http://www.ocxt.com/demo/samples/sample.doc"); document.OA1.LicenseName = ""; document.OA1.LicenseCode = ""; } function OA1_BeforeDocumentOpened() { document.OA1.DisableFileCommand(1, true);//wdUIDisalbeOfficeButton document.OA1.DisableFileCommand(2, true);//wdUIDisalbeNew document.OA1.DisableFileCommand(4, true);//wdUIDisalbeOpen document.OA1.DisableFileCommand(16, true);//wdUIDisalbeSave document.OA1.DisableFileCommand(32, true);//wdUIDisalbeSaveAs document.OA1.DisableFileCommand (512,true); //wdUIDisalbePrint (Ctrl+P) PES,PCT,CON document.OA1.DisableFileCommand (1024, true); //wdUIDisalbePrintQuick document.OA1.DisableFileCommand (2048, true); //wdUIDisalbePrintPreview } function OA1_DocumentOpened() { //You can do the office automation here //var objWord = document.OA1.ActiveDocument; //objWord.Content.Text = "You can do the office Automation with the Edraw Viewer Component."; document.all.OA1.SetAppFocus(); } function OA_DocumentBeforePrint() { //window.alert("OA_DocumentBeforePrint"); //document.OA1.DisableStandardCommand(4, true);//cmdTypePrint = 0x00000004, the line code will prevent the print } function OA_WindowBeforeRightClick() { //window.alert("OA_WindowBeforeRightClick"); //document.OA1.DisableStandardCommand(8, true);//cmdTypeRightClick = 0x00000008, the line code will prevent the right click } function OA_BeforeDocumentSaved() { //window.alert("OA_BeforeDocumentSaved"); //document.OA1.DisableStandardCommand(1, true);//cmdTypeSave = 0x00000001, the line code will prevent the save } //--> </SCRIPT> <script language="javascript"> window.onbeforeunload = function() { document.all.OA1.ExitOfficeApp(); } </script> <SCRIPT LANGUAGE=javascript FOR=OA1 EVENT=NotifyCtrlReady> <!-- OA1_NotifyCtrlReady(); //--> </SCRIPT> <script language="javascript" for="OA1" event="DocumentOpened()"> OA1_DocumentOpened(); </script> <script language="javascript" for="OA1" event="BeforeDocumentOpened()"> OA1_BeforeDocumentOpened(); </script> <script language="javascript" for="OA1" event="DocumentBeforePrint()"> OA_DocumentBeforePrint(); </script> <script language="javascript" for="OA1" event="BeforeDocumentSaved()"> OA_BeforeDocumentSaved(); </script> <script language="javascript" for="OA1" event="WindowBeforeRightClick()"> OA_WindowBeforeRightClick(); </script> <body> <table border="1" width="100%" height="100%" id="table1" bordercolorlight="#008080" bordercolordark="#008080" cellspacing="1"> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" style="height: 33px"> <p align="center"><b><font face="Verdana" size="5" color="#008080"> Edraw Office Viewer Component Demo</font></b><p align="center">Please Add the Website in the IE Trust Site List.</td> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" style="height: 33px"></td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" rowspan="18" width="81%"> <object classid="clsid:7677E74E-5831-4C9E-A2DD-9B1EF9DF2DB4" id="OA1" width="100%" height="100%" codebase="http://www.edrawsoft.com/download/officeviewer.cab#version=8,0,0,715"> <!-- NOTE: The officeviewer.cab file in edrawsoft.com is the trial version. If you have the full version, you should upload the officeviewer.cab file to your own site. Then change the codebase.//--> <param name="Toolbars" value="-1"> <param name="LicenseName" value="30daytrial"> <param name="LicenseCode" value="EDWD-3333-2222-1111"> <param name="BorderColor" value="15647136"> <param name="BorderStyle" value="2"> </object> <script language="JavaScript" type="text/javascript" src="NoIEActivate.js"></script> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="CreateWord()"> Create Word</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="CreateExcel()"> Create Excel</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="CreatePpt()"> Create PowerPoint</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="OpenFromLocal()"> Open From Local</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="OpenFromServer()"> Open From Server</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="ShowHideToolbar()"> Show Hide Toolbar</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="DocIsDirty()"> Is Modified</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="DisableHotKey()"> Disable Hot Key</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="PrintDoc()"> Print Doc</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="PrintPreview()"> Print Preview</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="ProtectDoc()"> Protect Doc</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="UnProtectDoc()"> Cancel Protect</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="DisableRightClick()"> Disable Right Click</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="SaveAs()"> Save As</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="SavetoServer()"> Save to Server</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="CloseDoc()"> Close Doc</div> </td> </tr> <tr> <td bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" width="17%"> <div class="Hlink" onClick="VBAProgramming()"> Office Automation</div> </td> </tr> </table> <p>Please make sure your computer has installed the Microsoft Office. If you find any question or suggest, please feel free to <a href="http://www.ocxt.com/"> contact us</a>.</p> </body> </html> Quote
herculanojs Posted November 22, 2016 Posted November 22, 2016 Hi, For now, I tried to display the doc, but it is works only in IE and with some "limitations" too... 1. Add the Website: https://www.edrawsoft.com in the IE Trust Site List 2. UniHTMLFrame1.HTML... <object classid="clsid:7677E74E-5831-4C9E-A2DD-9B1EF9DF2DB4" id="OA1" width="100%" height="100%" codebase="https://www.edrawsoft.com/download/officeviewer.cab#7,5,0,355"> <param name="Toolbars" value="-1"> <param name="BorderColor" value="15647136"> <param name="BorderStyle" value="2"> </object> 3. UniHTMLFrame1.AfterScript... document.all.OA1.Open("http://" + window.location.hostname + ":8077/files/uniGUI.docx", "Word.Application") Result: UniGUI_isthebest.png Best regards. I could make the demo available for this project ? Quote
mmurgas Posted August 17, 2017 Posted August 17, 2017 This is very useful, unfortunately only works with IE Quote
maniraj.baral@globant.com Posted June 5, 2018 Posted June 5, 2018 I used OleObject to convert .DOCX to .HTML and dislay in TUniURLFrame. Quote
Mehadi Hasan Posted February 17, 2021 Posted February 17, 2021 On 5/18/2016 at 12:07 PM, mmx110 said: Hi Forum unfortunately There is not Response to My question yet... I can load an ActiveX Object to UniHTMLFrame but How we can Pass Parameter or Receive Response from an Objects? for example sending Unibutton OnClick event to the Object inside the HtmlFrame or Receive Parameter From Object I want to Work with Event of an ActiveX Object as in Coding space in delphi... Best Regards Can you please give me a clue how to "load an ActiveX Object to UniHTMLFrame"? What activex components you used? And how? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.