Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Disable downloading from program using IE object

Posted on 2002-04-04
4
442 Views
Last Modified: 2008-02-01
I wrote a browser program using the Microsoft Internet Explorer object.  Is there a way to disable downloading of files inside my program?
0
Comment
Question by:vpl4
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
Ber earned 50 total points
ID: 6919771
You could evaluate the URL in the BeforeNavigate2 event to see if it is an allowable file type (In other words keep a list of the type of link you will allow the web browser to open such as html,htm,shtml,pl,asp ...etc...

however this would mean that you may end up excluding certain types of pages inadvertantly...

either way once you have evaluated the URL if it is acceptable set cancel to false otherwise set it to true..this is one way of stopping your users downloading files....

Hope this helps..
Cheers...
Ber...


BeforeNavigate2 Event

-----------------------------------------------------------

Fires before a navigation occurs in the given object (on either a window or frameset element).

Syntax

Private Sub object_BeforeNavigate2( _
     ByVal pDisp As Object, _
     ByVal URL As Variant, _
     ByVal Flags As Variant, _
     ByVal TargetFrameName As Variant, _
     ByVal PostData As Variant, _
     ByVal Headers As Variant, _
     ByVal Cancel As Boolean)
Parameters

object
Object expression that resolves to the objects in the Applies To list.

pDisp
Object that evaluates to the top-level or frame WebBrowser object corresponding to the navigation.

URL
String expression that evaluates to the URL to which the browser is navigating.

Flags
Reserved for future use.

TargetFrameName
String expression that evaluates to the name of the frame in which the resource will be displayed, or NULL if no named frame is targeted for the resource.

PostData
Data to send to the server if the HTTP POST transaction is being used.

Headers
Value that specifies the additional HTTP headers to send to the server (HTTP URLs only). The headers can specify such things as the action required of the server, the type of data being passed to the server, or a status code.

Cancel
Boolean value that the container can set to TRUE to cancel the navigation operation, or to FALSE to allow it to proceed.
Error Codes

No return value.
Remarks

Navigating to a different URL could happen as a result of external automation, internal automation from a script, or the user clicking a link or typing in the address bar. The container has an opportunity to cancel the pending navigation


Applies To

WebBrowser
Platform Version
Win32: 4.0
WinCE: 4.0
Version data is listed when the mouse hovers over a link, or the link has focus.
 InternetExplorer, WebBrowser
Move the mouse cursor over an element in the Applies To list to display availability information for the listed platforms. Internet Explorer does not expose this member on platforms that are not listed.
0
 
LVL 39

Expert Comment

by:appari
ID: 6919904
write cancel=true in filedownload event.

here is the details about filedownload event from MSDN online
*********************************
FileDownload Event  
--------------------------------------------------------------------------------

Fires to indicate that a file download is about to occur. If a file download dialog is to be displayed, this event is fired prior to the display of the dialog.

Syntax

Private Sub object_FileDownload( _
     ByRef bCancel As Boolean)
Parameters

object
Object expression that resolves to the objects in the Applies To list.
bCancel
Boolean that specifies whether to continue the download process and display the download dialog.

false
Default. Continue with the download process and display download dialog.
true
Cancel the download process.

Remarks

This event allows alternative action to be taken during a file download.



0
 
LVL 39

Expert Comment

by:appari
ID: 6919906
sorry write bCancel=true in that event
0
 

Author Comment

by:vpl4
ID: 6930010
Thanks Ber, this would allow me to limit certain downloads and not every single one of them.  It is the right thing I needed.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 65
Visual Studio 2005 text editor 10 44
Passing a Text Box name to a Sub 6 99
Send outlook email from VBS Script 2 42
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question