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;

Inserts text content to opened Word file programmatically

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

Inserts a picture to opened Word file programmatically

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

Inserts a break to opened Word file programmatically

boolean InsertBreak([in] WdBreakType BreakType);
Inserts a break to opened Word file.
BreakType: The break type. WdBreakType.
typedef enum WdBreakType
{
wdPageBreak = 7,
wdColumnBreak = 8,
wdSectionBreakNextPage = 2,
wdSectionBreakContinuous = 3,
wdSectionBreakEvenPage = 4,
wdSectionBreakOddPage = 5,
wdLineBreak = 6,
wdLineBreakClearLeft = 9,
wdLineBreakClearRight = 10,
wdTextWrappingBreak = 11,
}WdBreakType;
Example
The following java script shows how to insert a line break.
function InsertBreak_Example ()
{
Edword.InsertBreak( 6 );
}

How to disable the file command buttons

The Office Viewer Component provides the method “EnableFileCommand” to allow the developers to disable the File command in the MS office program.

If you are developing a web application, you can set the initial functions in the “NotifyCtrlReady” event.

function OA1_NotifyCtrlReady() {
document.OA1.EnableFileCommand(0) = false; //FileNew = 0
}
<SCRIPT LANGUAGE=javascript FOR=OA1 EVENT=NotifyCtrlReady>
<!–
OA1_NotifyCtrlReady();
//–>
</SCRIPT>

More File Command ENUMS:

typedef enum FileCommandType
{
FileNew = 0,
FileOpen,
FileClose,
FileSave,
FileSaveAs,
FilePrint,
FilePageSetup,
FileProperties,
FilePrintPreview
} FileCommandType;

Edraw Office Viewer Component 5.3.407 Released

5.3.407.1 version is a maintenance update.

1. Provided the silent print for the MS office document.

2. Added WordGetCurrentPageIndex and WordGetTotalPageCounts to return the current page number and page counts in Word document. 

3. The ExcelGetCellValue won’t returns null when the date is numeric;

4. Supported to open an Office 2007 file from the remote server with the “Open” method directly.

5.3.288.1

1. Fixed the buffer overflow to execute arbitrary code via a long first argument to the HttpDownloadFileToTempDir method and FTPDownloadFile.

2. Solved the failture when saving an Excel document to the server and having a cell activated.

3. Removed the default overwrite reminder from Microsoft Excel if you save an open Excel file at the same position multiple times.

4. Solved: Return to the first page if you click the Document Map in a protected Microsoft Word document

5. Solved: The excel process keeps back when call the “OfficeProtectDocument” method.

6. Some other small improvements.

How to upgrade the activex control in your program

After uninstall the old version and install the upgrade version, follow steps.

For HTML, PHP, ASp, JSP, ASP.NET application, you need change the version number in the Object tag.

<object classid=”clsid:6BA21C22-53A5-463F-BBE8-5CF7FFA0132B” id=”OA1″ width=”674″ height=”500″ codebase=”http://www.ocxt.com/download/officeviewer.cab#6,0,612,1“>

For VC project, you need go to the form and delete the component. Then delete the OfficeViewer1.h and OfficeViewer1.cpp file from your project. Save project then add the Edraw Office Viewer Component from the Toolbox. Then create a blank VC project based on Dialog. Add Edraw office Viewe Component to the Toolbox. Drag it to the dialog. Add variable for the component. You can find the OfficeViewer1.h and OfficeViewer1.cpp file in the new project. Copy the two files to your exsit project. Add exsit items…

For VB project, you need modify these files.

In OfficeViewer.frm

Object = “{F6F03022-1646-4426-A912-1F26464E81AB}#6.0#0″; “officeviewer.ocx”

In OfficeViewer.vbp

Object={F6F03022-1646-4426-A912-1F26464E81AB}#6.0#0; officeviewer.ocx

For C# or VB.NET project, you need delete the component from your form. Then delete the AxOfficeViewer and OfficeViewer references. Then right click the Toolbox and choose item… In the popup Choose Toolbox Items dialog click the COM Component. Then click the Browse… In the Edraw Office Viewer  component install folder, choose the officeviewer.ocx. Then click OK. Drag the component to your form.

Microsoft Word right-click menu doesn’t work

The combination of IE7 and Microsoft Word 2007 results in the failure of the Microsoft Word right-click menu.  The right-click menu starts to come up, and then it immediately disappears. I tested this on multiple web clients and they all had the same problem.

The MS Word right-click menu works with older versions of IE and older versions of MS Word, but the combination of IE7 and MS Word 2007 seems to cause the right-click MS Word menu to fail.