How to insert HTML table into Word doc using Javascript?

Use Edraw Office Viewer Component or Word Viewer Component to get the Document interface, then you can do it by the office automation.

document.OA1.CreateNew(“Word.Document”);
var objWord = document.OA1.ActiveDocument;
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 = “examples 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 = “examples 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 = “examples 3″

Disables the hotkeys in the MS Word programmatically

Edraw Viewer Component for Word provides some methods to disable the print, save and copy hotkeys.

boolean DisableSaveHotKey(boolean Disable);
Disables the Save keycodes.
Disalbe: Disables the CTRL+S, SHIFT+F12, Alt+SHIFT+F2, F12
boolean DisablePrintHotKey(boolean Disable);
Disables the Print keycodes.
Disalbe: Disables the CTRL+P, CTRL+SHIFT+F12, CTRL+F2, ALT+CTRL+I
boolean DisableCopyHotKey(boolean Disable);
Disables the Copy keycodes.
Disalbe: Disables the CTRL+C, CTRL+V, CTRL+X, SHIFT+DEL, SHIFT+INSERT, ALT+CTRL+V,
CTRL+SHIFT+C, CTRL+INSERT

You can call these methods at the DocumentOpened event.

Protect word document from changes

Edraw Word Viewer Component added the ProtectDoc method which helps to protect the specified document from changes. When a document is protected, users can make only limited changes, such as adding annotations, making revisions, or completing a form.

boolean ProtectDoc(WdProtectType ProtectType, [in, optional]
VARIANT Password);
ProtectType: The protection type for the specified document. WdProtectionType.
Password: Optional Object. The password required to remove protection from the specified
document.
enum WdProtectType
{
wdAllowOnlyRevisions = 0,
wdAllowOnlyComments = 1,
wdAllowOnlyFormFields = 2,
wdAllowOnlyReading = 3,
wdNoProtection = -1,
}WdProtectType;
Example
The following vb script shows how to protect a document for only revisions.
Sub ProtectDoc_Example()
edword.ProtectDoc 0
End Sub

Add some text at the end of Word document

How to add some text at the end of document that is opened in Edraw office viewer, Kindly send me java script code so that i can enter signatures in my document. Please reply as soon as possible and send my java script Example.

Embedding ms office in C# Forms

With Edraw Office Viewer Component, it’s easy to embed the ms office program in c# froms or html pages. Only drag it to your form, you can call some method to do the office automation directly such create a Word document or initialize an Excel sheet.

1. Download Edraw Office Viewer Component then install it. Or you can register the officeviewer.ocx using regsvr32 command.
  C:\\WINNT\System32\regsvr32 OfficeVidewer.ocx
2. On successful registration you would get message dialog.
3. Add Office Viewer Active-X control on your form through customize toolbox window.
4. Drag and drop component from toolbox on your form and resize as per requirement.
5. Now add reference for “Microsoft Word Object Library 11.0″ from add reference on solution explorer. Here I am using Word 2003, so object library version is 11.0.
6. You can see all added reference on solution explorer as shown in figure. Two reference has been added for Edraw Office Viewer  Component (AxOfficeViewer and OfficeViewer) and three libraries for Office & Word (Microsoft.Office.Core and Office and Word).
7. Define a variable for word document in public section of form as
   public Word.Document oDoc;
8. Add following code for button click event
private void button1_Click(object sender, System.EventArgs e)
{
     //Remove Office Viewer Component Title Bar and create a new Word document
     axOfficeViewer1.Titlebar = false;
     axOfficeViewer1.CreateNew(“Word.Document”);
     axOfficeViewer1.Activate();
     //Invoke Word properties
     oDoc = (Word.Document)axOfficeViewer1.ActiveDocument;
     oDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
     oDoc.ActiveWindow.DisplayRulers = false;
     oDoc.ActiveWindow.DisplayScreenTips = false;
     oDoc.ActiveWindow.DisplayHorizontalScrollBar = false;
     oDoc.ActiveWindow.DisplayVerticalRuler = false;
     oDoc.ActiveWindow.DisplayVerticalScrollBar = true;
}
10. Now you can add text, format it, send mail do all functionalities.
11. You can control all word functionalities to be made available or unavailable programmatically through code with all available objects, properties & Methods of word.

 

About the Application method

The new version has the GetApplication method.  You can use it to replace the Application method.
 
If you want to call the print dialog, you can use the follow method.
 
EDOffice.PrintDialog

Play slideshow in the same window

Edraw Office Viewer Component provides a solution for opening then playing the slideshow file in the same window. Of course you can play it with full screen mode too.

Simply call the “SlideShowOpenAndPlay” method, you can get the follow effect immediately.

PowerPoint Viewer ActiveX Control

You can show or hide the titlebar, screenbar, toolbar too.

You can call it via javascript or vbscript in your html page as follow.

document.OA1.SlideShowOpenAndPlay(“http://www.ocxt.com/demo/samples/sample.ppt“, false, false, false, false);

OR:

OA1.Open(“http://www…./sample.pps“, “PowerPoint.Slide”);

OA1.SlideShowPlay(false, false, true, false);

[id(99), helpstring("Opens then plays the PowerPoint slide show file in the same window or full screen.")]
HRESULT SlideShowOpenAndPlay([in] VARIANT Document, [in] VARIANT_BOOL bFullScreen, [in] VARIANT_BOOL bShowWebToolbar, [in] VARIANT_BOOL bLoopUntilStopped, [in] VARIANT_BOOL bShowScrollBar, [in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword);

[id(100), helpstring("Plays the PowerPoint slide show file in the same window or full screen.")]
HRESULT SlideShowPlay([in] VARIANT_BOOL bFullScreen, [in] VARIANT_BOOL bShowWebToolbar, [in] VARIANT_BOOL bLoopUntilStopped, [in] VARIANT_BOOL bShowScrollBar);

How to do the office automation in Delphi

We want to use this component to pilot Word and Visio documents, but we have certain problems and I would like to ask you some questions :

In Word, I use bookmarks to automatically insert data, like date, name of the user. To do this, in my code I use WordGotoItem function :

    OfficeViewer_1.WordGotoItem(wdGoToBookmark, wdGoToFirst, 1, ‘Name’);

but it doesn’t work, and I don’t know why.

Could you give me more information about this function and what’s wrong in my code ?

And I have another question :

How do I reach the header or footer of the word document ? Is there a function ?

 

Edraw Office Viewer Component can work in Delphi 2007/2009 for the office automation.

For example:
 
var
p1,p2: OleVariant;
OleAPP,OleDoc,MenuBar: OleVariant;
begin
  OfficeViewer.Toolbars:=FALSE; 
  OfficeViewer.Titlebar:=FALSE;
  p1:=DocFileName;
  p2:=TRUE;
  OfficeViewer.Open(DocFileName);
  OleDoc:=OfficeViewer.ActiveDocument; // IDispatch Document
  OleAPP:=OleDoc.application; // IDispatch Document.application
  // ——— WORD —————————————
  OleAPP.ActiveWindow.DisplayRulers := False;
  OleAPP.ActiveWindow.View.Type := 1; // wdNormalView=1
  // no popup
  oleDoc.CommandBars['Text'].Enabled := False;
  try
   OleDoc.Protect(1,Null,’ppkLock’);
  except
  end;
end;

Replace words in Office ActiveX Control

In my ASPX page I want to find and replace some predefined words. I am
using the following code, but it say objWord.Selection is not there. (
where as this is supported by word )
Set objWord = document.OA1.ActiveDocument
Set objSelection = objWord.Selection
objSelection.Find.ClearFormatting
objSelection.Find.Replacement.ClearFormatting
objSelection.Find.Text = varFind
objSelection.Find.Replacement.Text = varReplace
objSelection.Find.Forward = True
objSelection.Find.Wrap = wdFindContinue
objSelection.Find.Format = False
objSelection.Find.MatchCase = False
objSelection.Find.MatchWholeWord = False
objSelection.Find.MatchWildcards = False
objSelection.Find.MatchSoundsLike = False
objSelection.Find.MatchAllWordForms = False
objSelection.Find.Execute
Please let me know how can I find and replace word in the client side
word with OA1 activeX.

Inserts a file to opened Word file programmatically

boolean InsertFile([in] BSTR FilePath, [in, optional] VARIANT
InDocPos);
Inserts a file to opened Word file.
FilePath: The file path need to be inserted.
InDocPos: The insert position. WdInPocPos.
enum WdInDocPos
{
wdInDocumentPosCursor = 1,
wdInDocumentPosStart = 2,
wdInDocumentPosEnd = 3 ,
}WdInDocPos;