Visual Basic lessons learned

Apparently i have to fix the code in Visual Basic Language.

Here is things i learned:

Open VBS editor in Microsoft Excel 2002

ALT+F11
It is possible to directly send the content of excel workbook to Microsoft Outlook with simple command:
Application.Dialogs(xlDialogSendMail).Show

Assign string value into variable

variable = "hello world"

Convert %userprofile% windows variable into Visual Basic variable

Set oShell = CreateObject("WScript.Shell")
strHomeFolder = oShell.ExpandEnvironmentStrings("%USERPROFILE%")

Set time stamp into variable

RightNow = Format(Now(), "yyyymmddHHMMSS")

Set custom path by merging together variables

NewFileName = strHomeFolder & "\" & RightNow & ".log"

Save As all excel workbook in new file

ActiveWorkbook.SaveCopyAs (NewFileName)

Remove temporary file

Dim FileToDelete
Set FileToDelete = CreateObject("Scripting.FileSystemObject")
FileToDelete.DeleteFile (NewFileName )

No comments: