Attribute VB_Name = "modChangeTags"
'=========================================================================================
' modChangeTags - For ChangeTags.mvba
' Allows user to modify Tags in Design files.
'=========================================================================================
' Revision History
' Version  Person  Reason
' 1.0.0 to
' 1.1.3    CDJ     Orginal version befor revision history started
' 1.1.3    CDJ           Orginal version befor revision history started
' 1.2.0    RLS   08 2008 Interface cleanup, addition of EXIT button, check for versions
'                  to    Ability to do all models in a design file
'                09 2008 This File: Added Comments Only
'=========================================================================================
' Naming Conventions:
'   gc...   = Global Constant
'   gf...   = Global Flag (true/false)
'   g....   = Global variables
'
'=========================================================================================
' General Section
'=========================================================================================
Option Base 0          '-=>Array lower bound is 0
Option Explicit        '-=>Must declare ALL variables
Option Compare Text    '-=>Text comparsions are Case InSensitive [A=a]

'Name of template file for Excel spreadsheet:
'Private Const excelTemplateFileName = "ChangeTags.xlt"
'Private Const excelFileName = "TagData.xls"  '-=>Excel spreadsheeet file
Private Const excelTemplateFileName = "ChangeTagsM.xlt" '-=>For Testing
Private Const excelFileName = "TagDataM.xls"  '-=>For Testing
Public gExcelTemplateFile As String  '-=>Full path of excel template file
Public gExcelFile As String          '-=>Full path of excel spreadsheet

Public gFilePath As String           '-=>File path for template and spreadsheet files
Public gSavedFileListPath As String  '-=>File path for saved file lists
Public Const gSavedFileListFolder = "SavedFileLists"

'=========================================================================================
'================================> End of Declarations <==================================
'=========================================================================================

'=========================================================================================
' Sub: ChangeTags
'     Initialize stuff and show the form
'=========================================================================================
Public Sub ChangeTags()
    Dim templateDir As String
    
    gFilePath = ActiveDesignFile.path  '-=>Save file path for the Excel spreadsheet
    gSavedFileListPath = gFilePath & "\" & gSavedFileListFolder
    gExcelFile = AppendSlash(gFilePath) & excelFileName  '-=>Get file path for excel spreadsheet
    '-=> Get file path for the Excel template:
    templateDir = ActiveWorkspace.ConfigurationVariableValue("MS_VBANEWPROJECTDIRECTORY")
    gExcelTemplateFile = AppendSlash(templateDir) & excelTemplateFileName
    '-=> Check that template file is present:
    If Len(Dir(gExcelTemplateFile)) = 0 Then
        MsgBox "Did not find excel template file: " & gExcelTemplateFile & _
                vbNewLine & "Please contact your system administrator."
        Exit Sub
    End If
    
    frmChangeTags.Show vbModeless
    ShowMessage "ChangeTags: Loaded"
    ShowStatus "ChangeTags: Excel Template Dir = " & templateDir
End Sub

'=========================================================================================
' Function: AppendSlash
'          Append a "\" character to strDir if there is not one already.
'=========================================================================================
Public Function AppendSlash(strDir As String) As String
    If Right(strDir, 1) = "\" Then
        AppendSlash = strDir
    Else
        AppendSlash = strDir & "\"
    End If
End Function

'=========================================================================================
' Sub: CreateDirectory
'     Creates a new folder
'=========================================================================================
Public Sub CreateDirectory(path As String)
    On Error Resume Next
    MkDir path
End Sub
