Read-Only Office Viewer for Word, Excel and PowerPoint

Open Word, Excel in VB Form

How to open a shared, read-only MS Word document in MS Word inside of the application upon clicking a command button? Office Viewer Component allows visual basic developers to open, close, edit, print Word document and Excel workbook inside the VB form. The component supports seamless integration with Office 97, Office 2000, Office 2003, Office 2007 and Office 2010.

Edraw Office Viewer Component supports embedding Office documents in your application by implementing a full featured ActiveX document container. Now you can create, open, edit, view and save office documents such as *.doc, *.docx, *.xls, *.xlsx, *.ppt, *.pptx etc in the web page. With Office component you can have Office run embedded inside your custom solution.

Download Office Viewer Component and View Sample Projects

How to Open Word Excel File in VB

1. From the Project Menu select Components...

2. Select control "Edraw Office Viewer Component Module" in the controls table.

3. Click the OK Button.

4. The control will now appear in your toolbox.

5. Drag and drop the control on your form.

6. Right click the control then choose the View Code item.

7. Add the NotifyCtrlReady event and set the library file to load.

Private Sub Command1_Click()
End Sub

Private Sub Command2_Click()
End Sub

Private Sub Command3_Click()
If EDOffice1.Toolbars = False Then
EDOffice1.Toolbars = True
EDOffice1.Toolbars = False
End If
End Sub

Private Sub Command4_Click()
If EDOffice1.IsOpened = True Then
If EDOffice1.GetCurrentProgID = "Word.Application" Then
EDOffice1.ProtectDoc wdAllowOnlyFormFields
ElseIf EDOffice1.GetCurrentProgID = "Excel.Application" Then
EDOffice1.ProtectDoc XlProtectTypeNorma
End If
End If
End Sub

Private Sub Command5_Click()
End Sub

Private Sub EDOffice1_BeforeDocumentOpened()
''EDOffice1.SetValue "Password", "123"
''EDOffice1.SetValue "WritePassword", "456"
EDOffice1.DisableFileCommand wdUIDisalbeSave, True
EDOffice1.DisableFileCommand wdUIDisalbeSaveAs, True
EDOffice1.DisableFileCommand wdUIDisalbeSaveAsMenu, True
EDOffice1.DisableFileCommand wdUIDisalbePrint, True
EDOffice1.DisableFileCommand wdUIDisalbePrintQuick, True
End Sub

Private Sub EDOffice1_NotifyCtrlReady()
EDOffice1.LicenseName = ""
EDOffice1.LicenseKey = ""
End Sub

8. Run the project.

Open Word, Excel in VB

Support the Office Automation

Disables MS Word Standard Command

Disable Office Ribbon Button

Show/Hide Office Menu Bar

Free Download Office Viewer Component and View Sample Projects

Free Download Office Viewer Component

Copyright © EdrawSoft 2004 - 2014. All rights reserved.