Now, finally, let’s take the knowledge we have so far and start writing some code directed more towards automating DotNetNuke custom modules development. I am hopeful you have now been better oriented towards the inner workings of Visual Studio macros; assuming that is so, I will begin working at a faster pace. It should be readily obvious to you as I put forward more code that you needn’t copy it verbatim. As we move along you should consider taking a little extra time and substitute “Powerhouse Data” with your own company name. Or, as an alternative, substitute those items specific to my developing with your own name or initials. After all, that was one of my objectives of this tutorial: instilling the power to devise your own automation mechanisms.
There is much work yet to be done. There is a good deal of code to be written. However, the time spent now will pay big dividends in time saved later. To break up this “big” problem into more manageable pieces, I will create a series of macros, Test_001, Test_002, etc. And maybe this will also aid the learning process.
Here are some variables to be used repeatedly:
Dim MyOutput As OutputWindowPane Dim MyCompanyName, QualifierName, ModuleTitle, ModuleName, ProjectName As String
Dim ProjectPath, strtxt As String
Dim s As New System.Text.StringBuilder
Dim soln As Solution
Dim proj As Project
Dim projs As System.Array
Dim queryString As String
Dim i As Integer
Dim win As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
Dim OW As OutputWindow = win.Object
Dim OWp As OutputWindowPane
Dim owPTxtDoc As TextDocument
Insert them directly beneath
Public Module ModuleCreation
Dim MyOutput As OutputWindowPane
Create a subroutine named “Test_001”.
Insert the following code for this subroutine:
' ***** Portal Module Creation *****
' Powerhouse Data VSM Module Creation Macro
' Gets a Qualifier
' Gets a Module Name
' Automatically runs the Shaun Walker DotNetNuke Template
' ***** Title
MyOutput = AddOutputPane("Powerhouse Data Test_001")
Print(MyOutput, " ")
Print(MyOutput, " ***** Powerhouse Data VSM *****")
Print(MyOutput, " ")
Print(MyOutput, "Powerhouse Data VSM > Beginning at " & Now())
' ***** Qualifier
s.Length = 0 'clear the stringbuilder
s.Append("Qualifiers are necessary in order to prevent new modules from overwriting ")
s.Append("existing modules. Normally something such as your company name is used (e.g. Powerhouse).")
s.Append(vbNewLine)
s.Append(vbNewLine)
s.Append("What do you want to use as a Qualifier?")
QualifierName = InputBox(s.ToString, "Text used for Qualifier", "Powerhouse", 350, 350)
' ***** Module Name
s.Length = 0 'clear the stringbuilder
s.Append(vbNewLine)
s.Append("What do you want to use as a Module Name?")
ProjectName = InputBox(s.ToString, "Text used for Module Name", "PHD", 350, 350)
ModuleName = QualifierName & "_" & ProjectName ' Store complete module name here.
Print(MyOutput, "Powerhouse Data VSM > QualifierName = " & QualifierName)
Print(MyOutput, "Powerhouse Data VSM > ProjectName = " & ProjectName)
Print(MyOutput, "Powerhouse Data VSM > ModuleName = " & ModuleName)
Print(MyOutput, "Powerhouse Data VSM > ")
Print(MyOutput, "Powerhouse Data VSM > End " & Now())
Go ahead, save it, and run Test_001 in order to test it. You’ll see the following:

Having run Test_001 you can see what means I’ll be using to acquire information and subsequently how it can be reviewed in the Output window.