473,698 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,

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

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

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.

"planetthoughtf ul" <pl************ **@gmail.com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.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 SaveAccessObjec tsToFile()
Dim obj As AccessObject
Dim dbs As Object
Dim dbd As Object
Dim filesaveloc as string
Set dbs = Application.Cur rentProject
Set dbd = Application.Cur rentData
filesaveloc = "C:\Documen ts 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,

planetthoughtfu l
---
"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)

"planetthoughtf ul" <pl************ **@gmail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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 SaveAccessObjec tsToFile()
Dim obj As AccessObject
Dim dbs As Object
Dim dbd As Object
Dim filesaveloc as string
Set dbs = Application.Cur rentProject
Set dbd = Application.Cur rentData
filesaveloc = "C:\Documen ts 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,

planetthoughtfu l
---
"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('T ABLE_NAME');
if(ts.substr(0, 2)!='dt'){
r=c.Execute('SE LECT * 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
1913
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 datafile, e.g. wanted_image_data = datafileobj. The purpose is to hide external image files from the user in a simple game I'm writing. Though I have a good idea of how to implement this, before I begin I am curious to know if some Python master out...
2
3889
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 task. I know I can NAVIGATE to the page with the MS web browser control, but at that point I am stumped as to wether I can even save the page... TIA
3
1045
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 to do this in a module, but the module doesn't know anything about the request object in the webform. In otherwords, I would like to pass the filename to a function in a module and then the file is saved to a local drive by the function.
9
2777
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 IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
2
10985
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 "Save As" dialog and the ability to grab the filepath so that the second export appends to it. Anyway, I found Microsofts method and it works, except that I can't figure out how to populate the File Name box in the Dialog with a default name (say,...
21
34412
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
2
2093
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 name="_ct99:Content:UsrName" type="text" id="_ct99_Content_UsrName" /> <input name="_ct99:Content:Pwd" type="password" id="_ct99_Content_Pwd" /> <input type="submit" name="_ct99:Content:btnLogon" value="Logon"
18
34786
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."? Have you looked around trying to find simple solutions but didn't want to wade through pages of complex code? Have you balked at paying for premade solutions that are probably overkill for your particular project? I'd like to walk you through the...
16
7239
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 Fairfield to accomplish the first step: Private Sub SaveObjectsAsText() path = CurrentProject.path & "\ObjectsAsText\" SaveDataAccessPagesAsText SaveFormsAsText SaveReportsAsText
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9023
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7721
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.