+ All Categories
Home > Documents > Running External Applications 1. There are times when you may wish to run an external application...

Running External Applications 1. There are times when you may wish to run an external application...

Date post: 18-Jan-2018
Category:
Upload: terence-dalton
View: 226 times
Download: 0 times
Share this document with a friend
Description:
As another example, you are asked to create a VB program that tests a user’s knowledge of Microsoft Word. Part of the test is multiple choice (like Assignment-6) and part is hands-on. From your VB program, you want to open Word and a specific document, have the user make changes to the document, and then save it. This can be done using the Shell Method or the Process Class. 3 External Applications After learning about these two options, we will use them to create the interface shown on the previous slide. After learning about these two options, we will use them to create the interface shown on the previous slide.
11
Running External Applicatio ns 1
Transcript
Page 1: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

RunningExternal

Applications1

Page 2: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

There are times when you may wish to run an external application from a VB application.

2

External Applications

Page 3: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

As another example, you are asked to create a VB program that tests a user’s knowledge of Microsoft Word. Part of the test is multiple choice (like Assignment-6) and part is hands-on. From your VB program, you want to open Word and a specific document, have the user make changes to the document, and then save it.

This can be done using the Shell Method or the Process Class.

3

External Applications

After learning about these two options, we will use them to create the interface shown on the previous slide.

Page 4: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

Shell(“application_name”, windows_style)

Shell(“c:\windows\notepad.exe”,AppWinStyle.NormalFocus)

Shell(“c:\Program Files\Microsoft Office\Office14\winword.exe FontTest.doc”,AppWinStyle.NormalFocus)

4

Shell Method

There are two additional parameters, but we will not examine them. See helpon the Shell method for details.

For additional window styles see:http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.appwinstyle.aspx

Since the paths can vary, using the Shell method on different computerscan cause problems. Even on the samecomputer, there can be problems.

You cannot split a string acrosstwo lines. I needed the room!

If no path is specified, VB searchesthe Documents folder not debug.

Page 5: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

Process.Start (“application_name”) Process.Start(“c:\windows\notepad.exe”)

Process.Start (“document_name”)

Process.Start(“FontTest.doc”)

5

Process Class

Since the paths can vary, using the Process.Start on different computer can cause problems. Even on the samecomputer, there can be problems.

If no path is specified, VB searchesthe debug folder not Documents.

The application associatedwith the file type is used.For additional information see

Help on the Process.Class

Page 6: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

Let’s look at VB and see how to create the interface to execute these three applications.

6

Page 7: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

Accessingthe

Web

7

Page 8: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

The first example we will look at is a VB project that opens the CIS 400 home page.

This is done by using the WebBrowsercontrol and setting some of its properties such as:

AllowNavigationDockUrl

8

Accessing the Web

For additional details about the WebBrowser class, visit:http://msdn.microsoft.com/en-us/library/5d67hf8a.aspx

Page 9: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

9

Let’s look at VB and see how to create this Web interface.

Page 10: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

As another example, suppose you are working for the IT department of a school system, and you are asked to limit student access to only specific Web sites and links on those sites.

Remember, in the previous topic, we were able to run IE from with VB. Unfortunately, IE has an address text box in which users can type any URL.

To prevent this, you will use VB to create a browser interface that does NOT contain an address text box, thereby preventing users from typing a URL.

10

Accessing the Web

You will also have to use someWebBrowser methods.

Page 11: Running External Applications 1. There are times when you may wish to run an external application from a VB application. 2 External Applications.

11

Let’s look at VB and see how to create this Web interface.

ListBox of approved sites.


Recommended