UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Print All Coding To A Text File, Access 2016    
 
   
MisterChips
post Jun 14 2019, 04:29 AM
Post#1



Posts: 68
Joined: 29-January 17



good morning.

Is there any way of printing out all of my coding into a text file please?

Ideally it would be a section of code for each form and report etc.,
Ideally with formatting included.

Any ideas please?

Go to the top of the page
 
DanielPineault
post Jun 14 2019, 04:56 AM
Post#2


UtterAccess VIP
Posts: 6,716
Joined: 30-June 11



You can print your VBA code.

File->Print
Then select Current Module or Current Project

You can also select the code you wish to print and then do File->Print which will in turn use the Selection option for the printing.

--------------------
Daniel Pineault (2010-2019 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
cheekybuddha
post Jun 14 2019, 05:23 AM
Post#3


UtterAccess VIP
Posts: 11,419
Joined: 6-December 03
From: Telegraph Hill


Or you can right-click on each module and choose 'Export File...'

You will get the save dialog and automatically name the file 'module_name.bas' (which you can change if you wanted to)

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
gemmathehusky
post Jun 14 2019, 06:38 AM
Post#4


UtterAccess VIP
Posts: 4,723
Joined: 5-June 07
From: UK


there's a code library that let's you edit code. You can iterate all the forms, reports and modules, and use that code to write out the code in the modules.

if you need a lot of this, it's easier than copying and pasting by hand.

--------------------
Dave (Male)

(Gemma was my dog)
Go to the top of the page
 
cheekybuddha
post Jun 14 2019, 10:52 AM
Post#5


UtterAccess VIP
Posts: 11,419
Joined: 6-December 03
From: Telegraph Hill


Who was suggesting copying and pasting?

--------------------


Regards,

David Marten
Go to the top of the page
 
isladogs
post Jun 14 2019, 11:58 AM
Post#6


UtterAccess VIP
Posts: 1,454
Joined: 4-June 18
From: Somerset, UK


In case the OP isn't aware, .bas files as mentioned by cheekybuddha are simple text files which can be read in any text editor.
As such there won't be any formatting though the layout should be unchanged.

--------------------
Go to the top of the page
 
cheekybuddha
post Jun 14 2019, 12:00 PM
Post#7


UtterAccess VIP
Posts: 11,419
Joined: 6-December 03
From: Telegraph Hill


@Colin, thanks.gif

I should have pointed that out.

--------------------


Regards,

David Marten
Go to the top of the page
 
ADezii
post Jun 14 2019, 12:56 PM
Post#8



Posts: 2,461
Joined: 4-February 07
From: USA, Florida, Delray Beach


The following Code should enable you to Print ALL Code in your Access Project to a File named Code Export.txt to the same Folder as your Database. This can be accomplished via a Single Click and should be easy to customize to your specific needs. I executed this Code against the Northwind 2007 Sample Database and a File (Export Code.txt) was generated which was 84KB in size. Simply send Code Export.txt to the Printer when you are ready.
CODE
Dim strCode As String
Dim mdl As Object
Dim intLineCtr As Integer
  
Open CurrentProject.Path & "\Code Export.txt" For Output As #1

'For each Code Component in the Project ...
For Each mdl In VBE.ActiveVBProject.VBComponents
  With VBE.ActiveVBProject.VBComponents(mdl.Name).CodeModule
    'Using the Count of Lines ...
    intLineCtr = .CountOfLines
      If intLineCtr > 0 Then
        strCode = .Lines(1, intLineCtr)
      End If
      Print #1, String(50, "=") & vbCrLf & mdl.Name _
                & vbCrLf & String(50, "=") & vbCrLf & strCode
  End With
Next

Close #1

MsgBox "Code Export completed", vbInformation, "Export Code"

Go to the top of the page
 
cheekybuddha
post Jun 14 2019, 03:13 PM
Post#9


UtterAccess VIP
Posts: 11,419
Joined: 6-December 03
From: Telegraph Hill


>> As such there won't be any formatting though the layout should be unchanged. <<
Most good text editors have a language colour setting for vbScript which will work just fine for most of your VBA.

--------------------


Regards,

David Marten
Go to the top of the page
 
rbianco
post Jun 14 2019, 04:00 PM
Post#10


UtterAccess VIP
Posts: 1,742
Joined: 28-March 03
From: Coppell, TX


I am surprised that no one has suggested the built-in Documenter.

Go to Database Tools>Database Documenter.

Select the Modules Tab> Select All, or select the desired Modules.
Click OK.
When the report appears, right-mouse click and export as text file.

One of the Main advantages of this feature is the optional inclusion of Properties and Permissions of the code, as well as the assignment of line numbering.

Give it a try. I will be surprised if this does not exactly meet your needs


--------------------
"If I have seen further, then it is by standing on the shoulders of giants" - Sir Isaac Newton
Go to the top of the page
 
isladogs
post Jun 14 2019, 04:48 PM
Post#11


UtterAccess VIP
Posts: 1,454
Joined: 4-June 18
From: Somerset, UK


The database documenter is useful for many things and it does indeed allow you to export code to a text file using the process you described.
However, if the user just wants to export code to a text file, the methods previously described are, in my opinion, far more straightforward.
Does the addition of line numbers prevent the exported file being imported directly into another database?

--------------------
Go to the top of the page
 
Phil_cattivocara...
post Jun 15 2019, 01:47 AM
Post#12



Posts: 304
Joined: 2-April 18



I understand this is not the real question but if anybody is interested in having a printed version of code inside an Access file, preserving format and with color like VBE, there is a (great, in my opinion) pure Access-VBA project here
[Access] Documentare i Progetti (BETA) - Document your projects (BETA)
Yes, this is the usual Italian page but the only thing to do is to download DocuScan.zip.
It is marked as BETA because from time to time the author improves it and sometimes it crashes (but this seems to be solved)
Printing is done with Access report, no third party software needed.

--------------------
Please forgive in advance my horrible English.
Go to the top of the page
 
isladogs
post Jun 15 2019, 03:29 AM
Post#13


UtterAccess VIP
Posts: 1,454
Joined: 4-June 18
From: Somerset, UK


Hi Phil
Thanks for the link which I've downloaded and tested
It scans the database objects very quickly and produces a very clear summary report of database objects, properties and references on the second scan
I also found a relationships report as a PDF
That's all rather impressive.

However, the only code I can see in the report are the record sources for each object and my USysRibbons ribbon code
I thought you meant it creates a report including all module code.
Am I missing something obvious?


--------------------
Go to the top of the page
 
Phil_cattivocara...
post Jun 15 2019, 04:00 AM
Post#14



Posts: 304
Joined: 2-April 18



QUOTE
That's all rather impressive.
I will refer it to the author and if you find bugs or anything else, let me know.I think you left default "Seleziona Livello Scan..." (Select Scan Level) to 1. You have to select 2 or 3 to see printed code in report. I do not know the real difference, sorry.

--------------------
Please forgive in advance my horrible English.
Go to the top of the page
 
isladogs
post Jun 15 2019, 06:03 AM
Post#15


UtterAccess VIP
Posts: 1,454
Joined: 4-June 18
From: Somerset, UK


Hi Phil
You're right. After running scan level 1 I tried to change the level but the selectors were disabled.
It seems modifying the level is only possible after the initial level 0 scan

The form zSettingsComntrolsProperties shows the difference between the scans done for each level
However I've since changed it to level 2 then level 3 which gave me a 266 page report on a smallish ACCDB FE of 2.6MB!

The level of detail is like having the database documenter on steroids and the code formatting is excellent.
It is a very impressive piece of work

I did get one error message which may or may not be important.
Will run another check later and contact the author if appropriate.
It would be good to have a fully English language version as well - that may be a fairly simple task.

However, like the built-in database documenter, it is no substitute for a simple export to a text file which is of course what the OP wanted

--------------------
Go to the top of the page
 
Phil_cattivocara...
post Jun 15 2019, 06:13 AM
Post#16



Posts: 304
Joined: 2-April 18



QUOTE
Will run another check later and contact the author if appropriate.
I write immediately to the author, to explain everything but he is very, very, very busy. He is not a programmer or such a thing, it makes everything for passion.

--------------------
Please forgive in advance my horrible English.
Go to the top of the page
 
isladogs
post Jun 15 2019, 06:58 AM
Post#17


UtterAccess VIP
Posts: 1,454
Joined: 4-June 18
From: Somerset, UK


Thanks but don't feel you need to do so.
Happy to contact him/her myself if & when I've looked at it properly

--------------------
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    19th July 2019 - 05:08 AM