A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Version and download



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 21st 06, 07:50 PM posted to microsoft.public.outlook.program_vba
Josianne
external usenet poster
 
Posts: 28
Default Version and download

I put the lastest version on my form on a web site. I want a VBscript that
can look up which version of form the user is using and if it's not the
lastest version I want to download automatically from the web site.
I want something like:
If item.formdescription.version "15.4" then
Download
End if
thanks,
Josianne
  #2  
Old March 22nd 06, 04:27 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Version and download

Well, you already have the version test there. Now you just need the code to
download your form.

Use something like this:

Set objIEApp = CreateObject("InternetExplorer.Application")
objIEApp.Navigate strUpdateURL
objIEApp.Visible = True

That would display the download page called for in the strUpdateURL string
(www.something.com/files/download.htm). If you changed that URL string to a
an executable link such as www.something.com/files/download.exe then the
download would run automatically if it's in something like an installer
package.

If you wanted to use code to download say an OFT file then you could use
something like this:

Call DownloadFileAndClearCache(strUpdateXML, strLocalFileName) where the
update URL string has the file location and the second argument has the
download file name and path.

That procedure is courtesy of one of the VB MVP's, Randy Birch:

Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal nLength As Long)

Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Copyright ©1996-2005 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''
Private Sub DownloadFileAndClearCache(sSourceUrl As String, sLocalFile As
String)
Dim hfile As Long

On Error Resume Next

'Attempt to delete any cached version of
'the file. Since we're only interested in
'nuking the file, the routine is called as
'a sub. If the return value is requires
'(calling as a function), DeleteUrlCacheEntry
'returns 1 if successful, or 0 otherwise, e.g.
' If DeleteUrlCacheEntry(sourceUrl) = 1 Then
' Debug.Print "cached file found and deleted"
' Else
' Debug.Print "no cached file for " & sourceUrl
' End If
'Note that the remote URL is passed as this is the
'name the cached file is known by. This does NOT
'delete the file from the remote server.
Call DeleteUrlCacheEntry(sSourceUrl)

If DownloadFile(sSourceUrl, sLocalFile) = True Then
'hfile = FreeFile
'Open sLocalFile For Input As #hfile
'Text1.Text = Input$(LOF(hfile), hfile)
'Close #hfile
End If
End Sub


Private Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean

On Error Resume Next

'Download the file. BINDF_GETNEWESTVERSION forces
'the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached
'copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, sSourceUrl, _
sLocalFile, BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Josianne" wrote in message
...
I put the lastest version on my form on a web site. I want a VBscript that
can look up which version of form the user is using and if it's not the
lastest version I want to download automatically from the web site.
I want something like:
If item.formdescription.version "15.4" then
Download
End if
thanks,
Josianne


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
version of forms Josianne Outlook - Using Forms 0 March 17th 06 01:22 PM
Moving from one version to another Rose Outlook - General Queries 3 March 16th 06 10:41 PM
How to make an old version of Office look like the new version? beefer Outlook - Installation 0 February 24th 06 10:59 PM
Should I deleat trail version and install real version ? Trail Outlook Outlook - Installation 0 January 27th 06 03:47 PM
Next version Tim Scott Mathews Outlook - General Queries 3 January 9th 06 08:21 PM


All times are GMT +1. The time now is 11:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.