Embedding Application Program Coding

by arun on January 28, 2009

1. The program code is very simple and each of the application is declared in the declaration part is given below:

Option Explicit

Public mywordapp As word. Application

Public myexcelapp As Excel.

Application

Public myaccessapp As Access.

Application

Public mypptapp As POWERPOINT.

Application

2. Clicking a menu item opens the required MS office application. Following click events opens MS word.

Private sub MSWORD_Click (Index As Integer)

Set mywordapp = Create Object (“word. application”)

Mywordapp.Visible = True ‘to maximize window

Mywordapp.WindowState = wdWindowStateMaximize

Mywordapp.Documents.Add

End sub.

3. Similarly, the following click events open other MS applications:

Private Sub MSACCESS_Click (Index As Integer)

Set myaccessapp = CreateObject (“Access.application”)

Myaccessapp. Visible=True

Myaccessapp.runcommand acCmdApp Maximize ‘to maximize window

End Sub

Private Sub MSEXCEL_Click (Index As Integer)

Set myexcelapp = Create Object (“excel. Application”)

Myexcelapp. Visible=True

Myexcelapp.Workbooks.Add ‘ to maximize window

Myexcelapp.Activeworkbooks.

Windows (1) . Window State = x1Maximized

End sub

Private Sub POWERPOINT Click (Index As Integer)

Set mypptapp = CreateObject (“powerpoint.application”)

Mypptapp. Visible = True

Mypptapp.presentation.add ‘to maximize window

Mypptapp.ActiveWindow. Window State = ppWindowMaximized

Mypptapp.ActivePresentation.

Slides. Add 1, pplayoutBlank

End Sub

4. MS Paint is opened by the following code:

Private Sub MSPAINT_Click (Index As Integer)

Shell “mspaint.exe”, vbMaximizedFocus

End sub

The shell command runs the executable file normally present in ‘system root\windows\system32\mspaint.exe’.

EMBED.FRM

Option Explicit

Public mywordapp As Word. Application

Public myexcelapp As Excel. Application

Public myaccessapp As Access. Application

Public myapptapp As POWERPOINT. Application

Private Sub EXITAPP_Click (Index As Integer)

MsgBox “Thank You! See You Again!”

End

End Sub

Private Sub MSACCESS_Click (Index As Integer)

On Error Resume Next

Set myaccessapp = CreateObject (“Access.application”)

Myaccessapp. Visible = True

Myaccessapp. Run Command acCmdAppMaximize ‘to maximize window

End Sub

Private Sub MSEXCEL_Click (Index As Integer)

On Error Resume Next

Set myexcelapp = CreateObject (“excel. Application”)

Myexcelapp. Visible =True

Myexcelapp. Workbooks. Add ‘to maximize window

Myexcelapp.ActiveWorkbook.windows (1).Window State = x1Maximized

End sub

Private Sub MSPAINT_Click (Index As Integer)

On Error Resume Next

Shell “mspain.exe”, vbMaximizedFocus

End Sub

Private Sub MSWORD_Click (Index As Integer)

On Error Resume Next

Set mywordapp = CreateObject (“word. application”)

Mywordapp. Visible = True ‘to maximize window

Mywordapp. Window State = wdWindowStateMaximize

Mywordapp. Document. Add

End Sub

Private Sub POWERPOINT Click (Index As Integer)

On Error Resume Next

Set mypptapp = CreateObject (“Powerpoint.application”)

Mypptapp. Visible=True

Mypptapp. Presentations. Add ‘to maximize window

Mypptapp. Active Window. Window State = ppWindowMaximized

Mypptapp. Active Presentation. Slides. Add 1, ppLayoutBlank

End Sub

Related Posts

  1. Embedding Application software made easy
  2. SIM APPLICATION TOOLKIT

Subscribe Now

If you enjoyed this article. Subscribe to the feed to get instantly updates of awesome article soon to come.

Leave a Comment

Previous post:

Next post: