Email Button For Updating Files On The User Machine

put this code in a button or hotspot in notes mail memo and attach a file (like
a word template) .
when the user will click the button the file attached will replace the file
that already on the
user machine.
you are not need to know where the user kepp his file , the script will locate
it and replace it .
we are using it for Office templates update .

Dim FSO As Variant
Dim Files As Variant
Dim SubFolders As Variant
Dim Drives As Variant
Dim initFolder As Variant
Dim TextFile As Variant
Dim filename As String
Dim DriveName As String
Dim DriveType As String
Dim w As notesuiworkspace
Dim doc As notesdocument
Dim rtitem As Variant
Dim temp As String

Sub Click(Source As Button)
Set w=New notesuiworkspace
Set doc=w.currentdocument.document
Set rtitem = doc.GetFirstItem( "Body" )
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Drives=fso.drives

Forall dr In Drives
If dr.DriveType=2 Then
Set initFolder = FSO.GetFolder(drivename)
Set SubFolders = initFolder.Subfolders
Set Files = initFolder.Files
If SubFolders.Count > 0 Then
Forall x In SubFolders
If fso.fileexists(x.path+"\"+filename) Then
Call UpdateFile(temp)
End If
End Forall
End If
End If
End Forall
If temp<>"" Then
Msgbox "File was successfully updated"
Msgbox "File is missing , you can detach the file manually"
End If
Set fso=Nothing
End Sub

Function UpdateFile(FullPath As String)
Call fso.DeleteFile(FullPath,True)
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
Call o.ExtractFile (FullPath)
End If
End Forall
End If
End Function

Function GetFileName()
If ( rtitem.Type = RICHTEXT ) Then
If (rtitem.EmbeddedObjects(0).Type = EMBED_ATTACHMENT ) Then
End If
End If
End Function

Function Recurse(CurFolder As Variant)
Dim Sub_RFolders As Variant
Dim RFolders As Variant
Set RFolders = CurFolder.SubFolders

Forall y In RFolders
Set Sub_RFolders = y.SubFolders
If fso.fileexists(y.path+"\"+filename) Then
Call UpdateFile(temp)
End If
If Sub_RFolders.Count > 0 Then
End If
End Forall
End Function

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.