We are currently improving our controls, and one of the things that is
important to us is version control. Of particular importance is the
ability to compare one version of a file with another version and see
the changes that have been made.
Is there an application to export all the VB code from an access
database to a text file, so that one can compare the text files from
one release to the text files from another release to see exactly what
changes have been made to the VB code?
Thanks in advance,
Saul
This code may do what you want:
**** code begin ****
Option Base 0
Option Explicit
Private Const MB_ICONEXCLAMATION = &H30&
Private Declare Function MessageBeep Lib "user32" _
(ByVal wType As Long) As Long
Dim BasePath As String
Dim Path As String
Dim SuffixTxt As String
Private Sub SaveObjectsAsText()
Path = CurrentProject.Path & "\ObjectsAsText" & Format(Now(),
"yyyymmddhhnnss") & "\"
MkDir Path
SuffixTxt = ".txt"
SaveDataAccessPagesAsText
SaveFormsAsText
SaveReportsAsText
SaveModulesAsText
MessageBeep MB_ICONEXCLAMATION
End Sub
Private Sub SaveDataAccessPagesAsText()
Dim FileName As String
Dim Name As String
Dim DataAccessPage As AccessObject
SysCmd acSysCmdSetStatus, "Saving Data Access Pages as Text"
For Each DataAccessPage In CurrentProject.AllDataAccessPages
Name = DataAccessPages.Name
FileName = Path & Name & SuffixTxt
SaveAsText acDataAccessPage, Name, FileName
Next DataAccessPage
End Sub
Private Sub SaveFormsAsText()
Dim FileName As String
Dim Name As String
Dim Form As AccessObject
SysCmd acSysCmdSetStatus, "Saving Forms as Text"
For Each Form In CurrentProject.AllForms
Name = Form.Name
FileName = Path & Name & SuffixTxt
SaveAsText acForm, Name, FileName
Next Form
End Sub
Private Sub SaveReportsAsText()
Dim FileName As String
Dim Name As String
Dim Report As AccessObject
SysCmd acSysCmdSetStatus, "Saving Reports as Text"
For Each Report In CurrentProject.AllReports
Name = Report.Name
FileName = Path & Name & SuffixTxt
SaveAsText acReport, Name, FileName
Next Report
End Sub
Private Sub SaveModulesAsText()
Dim FileName As String
Dim Name As String
Dim Module As AccessObject
SysCmd acSysCmdSetStatus, "Saving Modules as Text"
For Each Module In CurrentProject.AllModules
Name = Module.Name
FileName = Path & Name & SuffixTxt
SaveAsText acModule, Name, FileName
Next Module
End Sub
**** code end ****
--
Lyle
Search google newsgroups for the undocumented SaveAsText and
LoadFromText methods.
-Tom.
Visual SourceSafe (VSS) will do all this for you, you'll need the
Access/Office Developers whateveritscalledthisversion thingy to get
the integration since VSS goes on a file by file basis and your MDB is
just one file, the integration will export/import all objects as files
to do the checking in/out / comparing, etc.
The comparison in VSS is very good, it will show you the two files
side by side and colour code the differences (added/deleted/changed
lines of code). You can label projects and rollback to that version,
etc, branch a project, share objects between projects, etc. All good
stuff. Bit of a PITA to begin with but I don't think we could function
without it now.
--
If you try to fail, and succeed, which have you done?
(replace sithlord with trevor for email)
The SaveAsText approach is quite good (as the others have said).
You may find, however, that certain lines in the SaveAsText output are
always different. I don't have Access here to check, but from memory,
there are timestamps etc. that change from output to output. You can
code some simple post-processing to filter out the irrelevant
differences. Then use a freeware file comparison utility to display
the versions side by side.
If I needed to do such things on a regular basis, I'd probably go for
VSS. But for occasional use (eg. "Did I actually make any changes last
week?"), the approach above is not too bad.
TC
Since I am using Access 97, do not have accessobject so had to open
each form, use SaveAsText and then close again.
Lyle Fairfield <lyle...@yahoo.com> wrote in message news:<Xns93B15E289AEE0...@130.133.1.4>...
saul_m...@hotmail.com (Saul Margolis) wrote in message news:<c20aa081.03070...@posting.google.com>...
>Does anybody know of similar code to output VBA from Excel 97?
>
>
Use save as text (and undocumented function)...
SaveAsText acModule, NameOfModule, PathToTextOutput
For example:
SaveAsText acModule, "basMyModule", "C:\MyFolder\MyModule.txt"
Try it from the immediate (debug) window.
- Jim
Not sure why, but SaveAsText didn't seem to work for me. Perhaps it
only works in later versions of excel. I did find a solution though,
have pasted below.
Sub SaveVBAasText()
Dim iCount As Integer
Dim tFileName As String
Dim tPath As String
Dim SuffixTxt As String
tPath = ThisWorkbook.Path & "\ObjectsAsText" & Format(Now(),
"yyyymmddhhnnss") & "\"
MkDir tPath
SuffixTxt = ".txt"
'Now save
For iCount = 1 To
Application.VBE.ActiveVBProject.VBComponents.Count
tFileName = tPath &
Application.VBE.ActiveVBProject.VBComponents.Item(iCount).Name &
SuffixTxt
Application.VBE.ActiveVBProject.VBComponents.Item(iCount).Export
tFileName
Next
End Sub
Cheers,
Saul
Jim...@NOTdatacentricsolutions.com (Jim Allensworth) wrote in message news:<3f181387...@netnews.comcast.net>...