Permalink
Browse files

Added new VBE components to z_VBA

  • Loading branch information...
shapiromatron committed Aug 28, 2011
1 parent 8271aa6 commit 682fda8186cafd142b1d111b2e92637d882cb567
Showing with 92 additions and 50 deletions.
  1. +6 −6 Functions/z_GIT.bas
  2. +82 −0 Functions/z_VBA.bas
  3. +2 −3 GITbat.bat
  4. +2 −41 GITout.txt
View
@@ -19,18 +19,18 @@ Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccessas
Function CommitToGIT(OutputDir As String) As Boolean
'-----------------------------------------------------------------------------------------------------------
' CommitToGIT - Commits changes in all files to GIT repository
- ' - Directory must already contain a GIT repository
+ ' - Directory must already contain a GIT repository
' - In : OutputDir as string
' - Out: TRUE if succesful, FALSE if otherwise
' - Last Updated: 7/20/11 by AJS
'-----------------------------------------------------------------------------------------------------------
Dim CommitMessage As String
Dim ProcessID As Long
- On Error GoTo IsError
- Do
- CommitMessage = InputBox("Enter GIT commit input message: ", "GIT Revisions Message")
- Loop Until CommitMessage <> ""
+ On Error GoTo IsError
+ Do
+ CommitMessage = InputBox("Enter GIT commit input message: ", "GIT Revisions Message")
+ Loop Until CommitMessage <> ""
Open OutputDir & "GITbat.bat" For Output As #1
Print #1, "cd " & OutputDir 'change directory to tracking folder
Print #1, "git add -f . && git commit -a -m " & Chr(34) & CommitMessage & Chr(34)
@@ -85,4 +85,4 @@ Private Function IsProcessOpen(PID As Long) As Boolean
Else
IsProcessOpen = False
End If
-End Function
+End Function
View
@@ -130,3 +130,85 @@ IsError:
End Function
+'*********************************************
+'*/-----------------------------------------\*
+'*| |*
+'*| VBA OBJECT IMPORT/EXPORT FUNCTIONS |*
+'*| |*
+'*\-----------------------------------------/*
+'*********************************************
+Public Function ExportVBComponent(VBComp As vbide.VBComponent, _
+ FolderName As String, _
+ Optional FileName As String, _
+ Optional ByVal Extension As String, _
+ Optional OverwriteExisting As Boolean = True) As Variant
+ '-----------------------------------------------------------------------------------------------------------
+ ' ExportVBComponent - This function exports the code module of a VBComponent to a text
+ ' file. If FileName is missing, the code will be exported to
+ ' a file with the same name as the VBComponent followed by the
+ ' appropriate extension.
+ ' - Last Updated: 8/27/11 by AJS, created by GH
+ '-----------------------------------------------------------------------------------------------------------
+ Dim FName As String
+ On Error GoTo IsError
+
+ 'get extension (if not passed)
+ If Trim(Extension) = vbNullString Then
+ Extension = z_VBA.GetVBAFileExtension(VBComp:=VBComp)
+ End If
+
+ 'get filename and extension
+ If Trim(FileName) = vbNullString Then
+ FName = VBComp.Name & Extension
+ Else
+ FName = FileName
+ FName = FName & "." & Extension
+ End If
+
+ 'get full directory for export
+ If Right(FolderName, 1) = "\" Then
+ FName = FolderName & FName
+ Else
+ FName = FolderName & "\" & FName
+ End If
+
+ 'overwrite if needed
+ If Len(Dir(FName)) > 0 Then
+ If OverwriteExisting = True Then
+ Kill FName
+ Else
+ ExportVBComponent = ""
+ Exit Function
+ End If
+ End If
+
+ 'export component; return filename
+ VBComp.Export FileName:=FName
+ ExportVBComponent = FName
+ Exit Function
+IsError:
+ ExportVBComponent = CVErr(xlErrNA)
+ Debug.Print "Error in ExportVBComponent: " & Err.Number & ": " & Err.Description
+End Function
+
+Public Function GetVBAFileExtension(VBComp As vbide.VBComponent) As String
+ '-----------------------------------------------------------------------------------------------------------
+ ' GetVBAFileExtension - This returns the appropriate file extension based on the Type of
+ ' the VBComponent.
+ ' - Last Updated: 8/27/11 by AJS, created by GH
+ '-----------------------------------------------------------------------------------------------------------
+ On Error GoTo IsError:
+ Select Case VBComp.Type
+ Case vbext_ct_ClassModule, vbext_ct_Document
+ GetFileExtension = ".cls"
+ Case vbext_ct_MSForm
+ GetFileExtension = ".frm"
+ Case vbext_ct_StdModule
+ GetFileExtension = ".bas"
+ Case Else
+ GetFileExtension = ".bas"
+ End Select
+IsError:
+ ExportVBComponent = CVErr(xlErrNA)
+ Debug.Print "Error in ExportVBComponent: " & Err.Number & ": " & Err.Description
+End Function
View
@@ -1,3 +1,2 @@
-cd C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library\
-git add -f . && git commit -a -m "Various edits and fixes to z_Excel"
-ECHO.
+cd C:\Documents and Settings\Owner\My Documents\Dropbox\Excel\VBA_library\
+git add -f . && git commit -a -m "Added new VBE components to z_VBA"
View
@@ -1,43 +1,4 @@
-C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library>cd C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library\
+C:\Documents and Settings\Owner\My Documents\Dropbox\Excel\VBA_library>cd C:\Documents and Settings\Owner\My Documents\Dropbox\Excel\VBA_library\
-C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library>git add -f . && git commit -a -m "Added z_charts"
-[master 0aef664] Added z_charts
- Committer: unknown <16955@.icf-hq.icfconsulting.com>
-Your name and email address were configured automatically based
-on your username and hostname. Please check that they are accurate.
-You can suppress this message by setting them explicitly:
-
- git config --global user.name "Your Name"
- git config --global user.email you@example.com
-
-If the identity used for this commit is wrong, you can fix it with:
-
- git commit --amend --author='Your Name <you@example.com>'
-
- 11 files changed, 92 insertions(+), 38 deletions(-)
- delete mode 100644 Functions/h_Charts.bas
- create mode 100644 Functions/z_Charts.bas
- rewrite VBA.pnps (100%)
-
-C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library>cd C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library\
-
-C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library>git add -f . && git commit -a -m "Added Range_Set function"
-[master 01ab19d] Added Range_Set function
- Committer: unknown <16955@.icf-hq.icfconsulting.com>
-Your name and email address were configured automatically based
-on your username and hostname. Please check that they are accurate.
-You can suppress this message by setting them explicitly:
-
- git config --global user.name "Your Name"
- git config --global user.email you@example.com
-
-If the identity used for this commit is wrong, you can fix it with:
-
- git commit --amend --author='Your Name <you@example.com>'
-
- 5 files changed, 135 insertions(+), 84 deletions(-)
-
-C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library>cd C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library\
-
-C:\Documents and Settings\16955\My Documents\Dropbox\Excel\VBA_library>git add -f . && git commit -a -m "Various edits and fixes to z_Excel"
+C:\Documents and Settings\Owner\My Documents\Dropbox\Excel\VBA_library>git add -f . && git commit -a -m "Added new VBE components to z_VBA"

0 comments on commit 682fda8

Please sign in to comment.