How to insert HTML table into Word doc using Javascript?

Use Edraw Office 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″

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.

 

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.

How to start MS Office Automation for my Web Application

How to start MS Office Automation for my Web Application?
How to call Office Automation methods from JavaScript code?
What are the input and the output parameters type for the Office Automation methods?

View the follow samples:

function WordAutomation()
{
document.OA1.CreateNew( “Word.Document”);
var objWord = document.OA1.ActiveDocument;
objWord.Content.Text = “You can do the office Automation with the Edraw Office Viewer Component.”;

 
more examples:

Use the follow Javascript to insert a file in the header of MS Word.
function WordAutomation()
{
document.OA1.CreateNew(”Word.Document”);
var objWord = document.OA1.ActiveDocument;
objWord.Sections(1).Headers(1).Range.InsertFile(”c:\\test.docx”);
}

Get the line counts from the Word Component

I am using ASP.NET, C# version 2.0

My concern is that, when the user will close the document on the web
browser, my code will get the line-count through your control and save
in the DB.

Please help me to get line count of the opened document in the component
in the IE.

If possible please send me the sample code to get the line-count using
Javascript.

How do I insert a page break in the function of Word Automation

How do I insert a page break in the function of Word Automation. The instructions that I have tried do not
work:
     Set objWord = OA1.ActiveDocument
     Set objApp = OA1.Application
     objApp.Selection.InsertBreak Type:=wdPageBreak
Can you help?

Solution:

Use the number to replace the emun.
 
Set objApp = OA1.Application
objApp.Selection.InsertBreak 7

Macro make Office Automation Easier

Automation is a process that allows applications that are written in languages such as Visual Basic .NET or C# to programmatically control other applications. Automation to Word allows you to perform actions such as creating new documents, adding text to documents, mail merge, and formatting documents. With Word and other Microsoft Office applications, virtually all of the actions that you can perform manually through the user interface can also be performed programmatically by using automation. Word exposes this programmatic functionality through an object model. The object model is a collection of classes and methods that serve as counterparts to the logical components of Word. For example, there is an Application object, a Document object, and a Paragraph object, each of which contain the functionality of those components in Word.

You can call the interesting methods and properties that Microsoft Word provides to you to manipulate documents in Word. The best way to learn how to navigate the object models of Word, Excel, and PowerPoint is to use the Macro Recorder in these Office applications:

1. Choose Record New Macro from the Macro option on the Tools menu and execute the task you’re interested in.
2. Choose Stop Recording from the Macro option on the Tools menu.
3. Once you are done recording, choose Macros from the Macro option on the Tools menu, select the macro you recorded, then click Edit.

This takes you to the generated VBA code that accomplishes the task you recorded. Keep in mind that the recorded macro will not be the best possible code in most cases, but it provides a quick and usable example.

For example to open an existing file and append some text:

object fileName = “c:\\test.doc”;
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
EDrawOfficeViewer1.Open(ref fileName, ref missing, ref missing);
Word.ApplicationClass oWordApp = EDrawOfficeViewer1.GetApplication();
oWordApp.Selection.TypeText(”This is the text”);
oWordApp.Selection.TypeParagraph();