Access.2007.VBA.Bibl..

(John Hannent) #1
Get the User Templates path from the Word Options dialog.

Set appWord = WScript.CreateObject(“Word.Application”)
strUserTemplatePath = appWord.Options.DefaultFilePath(2) _
& “\”
Set fso = _
WScript.CreateObject(“Scripting.FileSystemObject”)
strTemplatePath = strUserTemplatePath & strTemplate
MsgBox “Source template and path: “ & strTemplatePath

On Error Resume Next

Set fil = fso.GetFile(strTemplatePath)
If fil Is Nothing Then
strPrompt = “Can’t find “ & strTemplate & _
“ in “ & strScriptPath & “ folder; canceling”
MsgBox strPrompt, vbCritical + vbOKOnly
Quit
Else
Set appExcel = WScript.CreateObject(“Excel.Application”)
appExcel.Visible = True
Set bks = appExcel.Workbooks
Set wkb = bks.Add(strTemplatePath)
Set wks = wkb.Sheets(1)
wks.Activate
End If

Miscellaneous Scripts ..............................................................................................


The next script is one I made to automate the process of deleting temporary files from Audible.com
downloads. These files are sometimes not automatically deleted and have to be deleted manually,
which is a nuisance; the Delete Audible Files.vbs script is listed as follows:

Dim fso
Dim strPath
Dim strFile
Dim strFilePath
Dim blnFound

Set fso = CreateObject(“Scripting.FileSystemObject”)
blnFound = False

strPath = “E:\Audible\Bin\”
strFile = “Debug.log”
strFilePath = strPath & strFile
If fso.FileExists(strFilePath) Then
fso.DeleteFile strFilePath
blnFound = True
End If

Part III Adding More Functionality to Office

Free download pdf