473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Acc2K3: is there a way to programatically save form / module code to external files?

Hi All,

Just wondering if anyone can tell me if it's possible to
programatically save Access2003 code (ie code behind forms, as well as
class modules) to external files?

I'd like to use versioning software to keep track of code changes, but
this would require being able to save the files easily to *.cls and
*.bas files.

Any help appreciated!

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org1

Apr 30 '06 #1
4 2323
The undocumented SaveAsText might give you what you want, e.g.:
SaveAsText acForm, "Form1", "C:\Form1.txt"

LoadFromText it the matching statement.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"planetthoughtful" <pl**************@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Hi All,

Just wondering if anyone can tell me if it's possible to
programatically save Access2003 code (ie code behind forms, as well as
class modules) to external files?

I'd like to use versioning software to keep track of code changes, but
this would require being able to save the files easily to *.cls and
*.bas files.

Apr 30 '06 #2
Hi Allen,

Thanks for the answer!

Here's some code, in case someone else looks for the same thing at a
later date:

Sub SaveAccessObjectsToFile()
Dim obj As AccessObject
Dim dbs As Object
Dim dbd As Object
Dim filesaveloc as string
Set dbs = Application.CurrentProject
Set dbd = Application.CurrentData
filesaveloc = "C:\Documents And Settings\" ' Edit to your preferred
save location
For Each obj In dbs.AllForms
SaveAsText acForm, obj.Name, filesaveloc & obj.Name & ".cls"
Next
For Each obj In dbs.AllModules
SaveAsText acModule, obj.Name, filesaveloc & obj.Name & ".bas"
Next
For Each obj In dbd.AllQueries
SaveAsText acQuery, obj.Name, filesaveloc & obj.Name & ".sql"
Next
End Sub

Note: I haven't been able to save table objects using "SaveAsText
acTable", but this may be because the tables are linked rather than
local to the mdb file executing this code.

Thanks again!

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org

Apr 30 '06 #3
There is no way to save as text the table objects. The best you
can do is use the SaveAsText command with option 6 to save a
binary copy of the database with it's table objects, minus
all the stuff exported by the other options.

This is the say MS Source Safe handles the database: every
thing else as text, tables and data in a single binary object.

Access 2003 has extended XML methods, and you may be able
to find code to document the tables and data as XML.

(david)

"planetthoughtful" <pl**************@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hi Allen,

Thanks for the answer!

Here's some code, in case someone else looks for the same thing at a
later date:

Sub SaveAccessObjectsToFile()
Dim obj As AccessObject
Dim dbs As Object
Dim dbd As Object
Dim filesaveloc as string
Set dbs = Application.CurrentProject
Set dbd = Application.CurrentData
filesaveloc = "C:\Documents And Settings\" ' Edit to your preferred
save location
For Each obj In dbs.AllForms
SaveAsText acForm, obj.Name, filesaveloc & obj.Name & ".cls"
Next
For Each obj In dbs.AllModules
SaveAsText acModule, obj.Name, filesaveloc & obj.Name & ".bas"
Next
For Each obj In dbd.AllQueries
SaveAsText acQuery, obj.Name, filesaveloc & obj.Name & ".sql"
Next
End Sub

Note: I haven't been able to save table objects using "SaveAsText
acTable", but this may be because the tables are linked rather than
local to the mdb file executing this code.

Thanks again!

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org

May 1 '06 #4
This is a JScript that saves a db's tabes as text (in two formats). It
should not take a lot to translate it over to VBA.

var r=new ActiveXObject('ADODB.Recordset');
var s=new ActiveXObject('ADODB.Recordset');

s = c.OpenSchema(20, Array(null, null, null, "Table"))
while(!s.EOF){
ts=s.Collect('TABLE_NAME');
if(ts.substr(0,2)!='dt'){
r=c.Execute('SELECT * FROM [' + ts + ']');
try{
f.DeleteFile('C:/DB_51315Backups/'+ts+'.adtg');
f.DeleteFile('C:/DB_51315Backups/'+ts+'.xml');
}
catch(e){
}
r.Save('C:/DB_51315Backups/'+ts+'.adtg',0)
r.Save('C:/DB_51315Backups/'+ts+'.xml',1)
}
s.MoveNext
}

May 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jacob H | last post by:
Hello all, Today I began writing a utility script that takes given binary files and puts them all into one datafile. My idea is to be able to access any binary data I want by indexing the...
2
by: Dave Bootsma | last post by:
Is it possible to programatically save a certain image from a certain web page? I want to automatically get a specific graphic from a specific web page programatically so I can automate the...
3
by: JJ_377 | last post by:
How would I use a module to save a file? I can use the html input (type-file) in a webform to select a file and then do a saveas on the request object's file. However, I would like to be able...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
2
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into the same file (a new worksheet). So I needed both a...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
2
by: Grey Alien | last post by:
I am trying to programatically POST an ASP form, to allow me to log on to a site programatically. <form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm"> <input...
18
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? ...
16
by: Wayne | last post by:
I've read that one method of repairing a misbehaving database is to save all database objects as text and then rebuild them from the text files. I've used the following code posted by Lyle...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.