Friday, February 10, 2012

Check if Directory Exists

Function DirExists (strPath As String) As Boolean
   DirExists = (Dir$ (strPath ,16 ) <> "" )
End Function

Tuesday, July 5, 2011

Some Excel VBA Tips

Get current directory:

ActiveWorkbook.Path

Format Date :

Format(Date, "mmmm_d_yyyy")


Format Time:
Format(Now, "Hh_Nn_Ss")

Replace special characters:

If you know the character code, use the following example:

Replace(str, Chr(149), "-")

Monday, November 2, 2009

Exit While Loop

There is no Exit While statement in LotusScript.
The solution is simple. Use the Do While ... Loop and then Exit Do if you want to break the loop.


-->

Thursday, March 26, 2009

Check if Form Exists


Function formExists (db As NotesDatabase, formType As String)
Dim formTypeYes As Boolean
Forall frm In db.Forms
If Isarray (frm.Aliases) Then
If frm.Aliases (0) = formType Then
formTypeYes = True
End If
End If
End Forall
formExists = formTypeYes
End Function

Wednesday, March 25, 2009

Create Subfolder

This function first checks to see if a subfolder exists, and creates one if it does not exist. The function returns the path. It is dependent on the DirExists function.
Function CheckMakeFolder ( root As String , leaf As String) As String
Dim strPath As String
strPath = root & "\" & leaf
If Not DirExists (strPath) Then
Mkdir strPath
End If
CheckMakeFolder = strPath
End Function

New Line Symbol

The new line symbol or carriage return and linefeed symbols can be inserted using the following combination:

Chr(13) & Chr(10)

Write String to File


Sub WriteLog (strLog As String, logFileName As String )
Dim fileName As String
Dim fileNum As Integer
fileNum% = Freefile()
fileName$ = logFileName
Open FileName$ For Append As fileNum%
Write #fileNum% , strLog
Close fileNum%
End Sub