This page will demonstrate how easy it is to build upon previous macro work.
In Macro Explorer, click once on the ASCII_Values macro in order to select it. Give it a right-click and then choose edit. Notice how the Microsoft Visual Studio Macros IDE (integrated development environment) immediately opens. Also notice it opens with your cursor conveniently placed within the ASCII_Values subroutine at the start of its code. While you are here do you see the Project Explorer window? Something to remember is that the memory is separated between these projects. So if you want to share the function such as the AddOutputPane as seen on the previous page, it needs to stay within your project (i.e. PHD_Macros).
Remember placing Dim MyOutput As OutputWindowPane directly underneath Public Module ModuleCreation? This allows the variable MyOutput to be shared throughout the subroutines within the project PHD_Macros.
So for further demonstration, insert the following code into the PHD_Macros project:
Sub Current_Environment()
Dim myDirectory As String
Dim thing, tempvalue As String
MyOutput = AddOutputPane("Current Environment")
Print(MyOutput, " ")
Print(MyOutput, " ***** Current Environment *****")
Print(MyOutput, " ")
Print(MyOutput, "Powerhouse Data VSM > Beginning at " & Now())
myDirectory = System.Environment.CurrentDirectory.ToString()
Print(MyOutput, "Powerhouse Data VSM > Current Directory> " & myDirectory)
myDirectory = System.Environment.MachineName.ToString()
Print(MyOutput, "Powerhouse Data VSM > Environment> " & myDirectory)
myDirectory = System.Environment.SpecialFolder.MyDocuments.ToString()
Print(MyOutput, "Powerhouse Data VSM > UserInteractive> " & myDirectory)
myDirectory = System.Environment.UserName.ToString()
Print(MyOutput, "Powerhouse Data VSM > UserName> " & myDirectory)
myDirectory = System.Environment.GetEnvironmentVariable("VS80COMNTOOLS")
Print(MyOutput, "Powerhouse Data VSM > GetEnvironmentVariable(""VS80COMNTOOLS"")> " & myDirectory)
myDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)
Print(MyOutput, "Powerhouse Data VSM > GetEnvironmentVariable(""MyDocuments"")> " & myDirectory)
Print(MyOutput, "GetEnvironmentVariables: ")
Dim environmentVariables As System.Collections.IDictionary = System.Environment.GetEnvironmentVariables()
Dim de As System.Collections.DictionaryEntry
For Each de In environmentVariables
Print(MyOutput, "> " & de.Key & " ~ " & de.Value)
Next de
End Sub
Insert the above code directly above the last line which is End Module. Save it. Leave the Microsoft Visual Studio Macros IDE and go back to Visual Studio and its Macro Explorer window. Run this new Current_Environment macro.
Even though that code was written just a little bit sloppy, when you view it in its Output window, I am hopeful it will make evident the potential for working with Visual Studio macros. Since my ability as an “Object Oriented” programmer is very poor, you should be confident that you can easily surpass what I’ve accomplished!