Getting code from .mdb to a text file

Getting code from .mdb to a text file

am 19.12.2007 17:16:57 von Thelma Lubkin

I did some work with Access .mdb's a couple of years ago. I was able
to save both the VBA code and a listing of properties for all form
objects to a text file that I could read without access to Access.

I've again begun to do some work with Access, but I've forgotten
how I did this, and I've even been unable to google
the trick...here's a short example of what I was getting:


X:\Applications\Access\Testit\parameterscb.mdb Saturday, October 29, 2005

Form: frmColor1 Page: 1

Properties

AllowAdditions: True AllowDatasheetView: True
AllowDeletions: True AllowDesignChanges: True
AllowEditing: True AllowEdits: True



X:\Applications\Access\Testit\parameterscb.mdb Saturday, October 29, 2005

Form: frmColor1 Page: 9

Code
1 VERSION 1.0 CLASS
2 BEGIN

3 MultiUse = -1 'True
4 END
5 Attribute VB_Name = "Form_frmColor1"

6 Attribute VB_GlobalNameSpace = False
7 Attribute VB_Creatable = True
8 Attribute VB_PredeclaredId = True

9 Attribute VB_Exposed = False
10 Option Compare Database
11

12 Private Sub SeqNo_GotFocus()
13 '
14 '

15 ' MsgBox (lngrecordnum)
16 ' DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7
17

18 ' CLASSSIZE IS NOT COMING FROM FORM
19 ' Dim csize As Integer
20 ' csize = Form!frmcolor2!CLASSSIZE

21 Dim nn As Integer
22 If Blue > 0 Then


I was using Access 2003 at the time. Now I can get to either Access
2003 or Access 2007. Please, how did I do this?

thanks, --thelma

Re: Getting code from .mdb to a text file

am 19.12.2007 18:09:05 von fredg

On 19 Dec 2007 16:16:57 GMT, Thelma Roslyn Lubkin wrote:

> I did some work with Access .mdb's a couple of years ago. I was able
> to save both the VBA code and a listing of properties for all form
> objects to a text file that I could read without access to Access.
>
> I've again begun to do some work with Access, but I've forgotten
> how I did this, and I've even been unable to google
> the trick...here's a short example of what I was getting:
>
> X:\Applications\Access\Testit\parameterscb.mdb Saturday, October 29, 2005
>
> Form: frmColor1 Page: 1
>
> Properties
>
> AllowAdditions: True AllowDatasheetView: True
> AllowDeletions: True AllowDesignChanges: True
> AllowEditing: True AllowEdits: True
>
>
>
> X:\Applications\Access\Testit\parameterscb.mdb Saturday, October 29, 2005
>
> Form: frmColor1 Page: 9
>
> Code
> 1 VERSION 1.0 CLASS
> 2 BEGIN
>
> 3 MultiUse = -1 'True
> 4 END
> 5 Attribute VB_Name = "Form_frmColor1"
>
> 6 Attribute VB_GlobalNameSpace = False
> 7 Attribute VB_Creatable = True
> 8 Attribute VB_PredeclaredId = True
>
> 9 Attribute VB_Exposed = False
> 10 Option Compare Database
> 11
>
> 12 Private Sub SeqNo_GotFocus()
> 13 '
> 14 '
>
> 15 ' MsgBox (lngrecordnum)
> 16 ' DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7
> 17
>
> 18 ' CLASSSIZE IS NOT COMING FROM FORM
> 19 ' Dim csize As Integer
> 20 ' csize = Form!frmcolor2!CLASSSIZE
>
> 21 Dim nn As Integer
> 22 If Blue > 0 Then
>
> I was using Access 2003 at the time. Now I can get to either Access
> 2003 or Access 2007. Please, how did I do this?
>
> thanks, --thelma

Access has a built-in documenter.
In Access 2003 and earlier:
Tools + Analyze + Documenter


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Re: Getting code from .mdb to a text file

am 19.12.2007 18:11:18 von Salad

Thelma Roslyn Lubkin wrote:

> I did some work with Access .mdb's a couple of years ago. I was able
> to save both the VBA code and a listing of properties for all form
> objects to a text file that I could read without access to Access.
>
> I've again begun to do some work with Access, but I've forgotten
> how I did this, and I've even been unable to google
> the trick...here's a short example of what I was getting:
>
>
> X:\Applications\Access\Testit\parameterscb.mdb Saturday, October 29, 2005
>
> Form: frmColor1 Page: 1
>
> Properties
>
> AllowAdditions: True AllowDatasheetView: True
> AllowDeletions: True AllowDesignChanges: True
> AllowEditing: True AllowEdits: True
>
>
>
> X:\Applications\Access\Testit\parameterscb.mdb Saturday, October 29, 2005
>
> Form: frmColor1 Page: 9
>
> Code
> 1 VERSION 1.0 CLASS
> 2 BEGIN
>
> 3 MultiUse = -1 'True
> 4 END
> 5 Attribute VB_Name = "Form_frmColor1"
>
> 6 Attribute VB_GlobalNameSpace = False
> 7 Attribute VB_Creatable = True
> 8 Attribute VB_PredeclaredId = True
>
> 9 Attribute VB_Exposed = False
> 10 Option Compare Database
> 11
>
> 12 Private Sub SeqNo_GotFocus()
> 13 '
> 14 '
>
> 15 ' MsgBox (lngrecordnum)
> 16 ' DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7
> 17
>
> 18 ' CLASSSIZE IS NOT COMING FROM FORM
> 19 ' Dim csize As Integer
> 20 ' csize = Form!frmcolor2!CLASSSIZE
>
> 21 Dim nn As Integer
> 22 If Blue > 0 Then
>
>
> I was using Access 2003 at the time. Now I can get to either Access
> 2003 or Access 2007. Please, how did I do this?
>
> thanks, --thelma

From the database Window I selected Tools/Analyze/Documenter.

Freefall
http://www.youtube.com/watch?v=ymdssZOAx3Q

Re: Getting code from .mdb to a text file

am 19.12.2007 18:19:30 von Thelma Lubkin

fredg wrote:
: On 19 Dec 2007 16:16:57 GMT, Thelma Roslyn Lubkin wrote:

:> I did some work with Access .mdb's a couple of years ago. I was able
:> to save both the VBA code and a listing of properties for all form
:> objects to a text file that I could read without access to Access.
:>
:> I've again begun to do some work with Access, but I've forgotten
:> how I did this, and I've even been unable to google...

: Access has a built-in documenter.
: In Access 2003 and earlier:
: Tools + Analyze + Documenter

Thank you. --thelma
: --
: Fred
: Please respond only to this newsgroup.
: I do not reply to personal e-mail

Re: Getting code from .mdb to a text file

am 19.12.2007 18:24:35 von Thelma Lubkin

Salad wrote:
: Thelma Roslyn Lubkin wrote:

:> I did some work with Access .mdb's a couple of years ago. I was able
:> to save both the VBA code and a listing of properties for all form
:> objects to a text file that I could read without access to Access.
:>
:> I've again begun to do some work with Access, but I've forgotten
:> how I did this, and I've even been unable to google
: From the database Window I selected Tools/Analyze/Documenter.

Thank you.
...and thanks for your earlier reply to my question about
a query where I was trying to make a criterion based on a
form variable: I've now restructured the thing so that it
works.
--thelma

Re: Getting code from .mdb to a text file

am 19.12.2007 18:52:36 von Benny Andersen

If you just want to backup all module vba code, the folowing function drops
it in the same directory as the .mdb file:

Function writeModulesText()
Dim dbs As Database, ctr As Container, modNames As New Collection
Dim i%, mName$, dbloc$, fileN$, archivename$, filelist$
Set dbs = CurrentDb()
filelist = Left$(dbs.name, InStrRev(dbs.name, ".") - 1) & "VbaMod.txt"
Open filelist For Output As #1
dbloc = parentFolder(dbs.name)
Set ctr = dbs.Containers!Modules
For i = 0 To ctr.Documents.count - 1
mName = ctr.Documents(i).name
saveCodeFile acModule, mName, dbloc, IIf(isUpper(mName), ".cls",
".bas"), 1: Next
Set ctr = dbs.Containers!Forms
For i = 0 To ctr.Documents.count - 1
mName = ctr.Documents(i).name
DoCmd.OpenForm mName, , , , , acHidden, codebackup
If Forms.item(mName).HasModule Then
saveCodeFile acForm, mName, dbloc, ".cls", 1
End If
DoCmd.Close acForm, mName: Next
Close #1
End Function
--
Benny Andersen

Re: Getting code from .mdb to a text file

am 19.12.2007 19:00:16 von Thelma Lubkin

Benny Andersen wrote:
: If you just want to backup all module vba code, the folowing function drops
: it in the same directory as the .mdb file:

: Function writeModulesText()


thanks, does this have any advantage over the analyzer that
others have mentioned?
--thelma

: Dim dbs As Database, ctr As Container, modNames As New Collection
: Dim i%, mName$, dbloc$, fileN$, archivename$, filelist$
: Set dbs = CurrentDb()
: filelist = Left$(dbs.name, InStrRev(dbs.name, ".") - 1) & "VbaMod.txt"
: Open filelist For Output As #1
: dbloc = parentFolder(dbs.name)
: Set ctr = dbs.Containers!Modules
: For i = 0 To ctr.Documents.count - 1
: mName = ctr.Documents(i).name
: saveCodeFile acModule, mName, dbloc, IIf(isUpper(mName), ".cls",
: ".bas"), 1: Next
: Set ctr = dbs.Containers!Forms
: For i = 0 To ctr.Documents.count - 1
: mName = ctr.Documents(i).name
: DoCmd.OpenForm mName, , , , , acHidden, codebackup
: If Forms.item(mName).HasModule Then
: saveCodeFile acForm, mName, dbloc, ".cls", 1
: End If
: DoCmd.Close acForm, mName: Next
: Close #1
: End Function
: --
: Benny Andersen

Re: Getting code from .mdb to a text file

am 19.12.2007 21:19:55 von Benny Andersen

On 19 Dec 2007 18:00:16 GMT, Thelma Roslyn Lubkin wrote:
> thanks, does this have any advantage over the analyzer that
> others have mentioned?
No, its purphose is just for backing up vba code, and that is a subset af
of the 'analyser'.
But it can be done automatical - built to be done on any event, and the
modules can bee imported to build modules.

I missed to send som utility funtions used by Function writeModulesText()

Function parentFolder$(Path, Optional sepC$ = "\")
Dim bslpos
bslpos = InStrRev(Path, sepC)
If bslpos = Len(Path) Then
bslpos = InStrRev(Path, sepC, bslpos - 1): End If
Path = Left(Path, bslpos)
parentFolder = Path
End Function

Sub saveCodeFile(asObject As AcObjectType, objName$, locSl$, ext$,
fileRangenumber%)
Dim fileN$
fileN = locSl & objName & ext
SaveAsText asObject, objName, fileN
Print #1, fileN
End Sub

--
Benny Andersen

Re: Getting code from .mdb to a text file

am 20.12.2007 05:14:39 von Salad

Thelma Roslyn Lubkin wrote:

> Salad wrote:
> : Thelma Roslyn Lubkin wrote:
>
> :> I did some work with Access .mdb's a couple of years ago. I was able
> :> to save both the VBA code and a listing of properties for all form
> :> objects to a text file that I could read without access to Access.
> :>
> :> I've again begun to do some work with Access, but I've forgotten
> :> how I did this, and I've even been unable to google
> : From the database Window I selected Tools/Analyze/Documenter.
>
> Thank you.
> ...and thanks for your earlier reply to my question about
> a query where I was trying to make a criterion based on a
> form variable: I've now restructured the thing so that it
> works.
> --thelma
>
>
Merry Christmas and a Prosperous New Year, Thelma!