MartyConnelly
martyconnelly at shaw.ca
Sat Dec 30 15:15:29 CST 2006
Saving tables is the one exception to this method instead use the DAP pages method, it is a carryover from the original Access 97 method where it was really undocumented as opposed to just MS undocumented. I got the original hint from Larry Lawson. 'This saves all tables, references, relationships, ' DAP's and command menus to one file. SaveAsText acDataAccessPage, "", strPath & "dbAllTablesText.txt" 'Save only once to one file so exit. ' the constant acDataAccessPage doesn't exist in Access 97 ' so use the magic number 6 Also you may not want to save temp Queries so If dbs.QueryDefs(i).Name, 1) <> "~" Then 'remove temp queries from selection 'using acTable = 0 with SaveAsText 'Tables won't work in 2003 or 97 ' you will get saveastext 2487 error. Martin Reid wrote: >Just fixing some stuff up. ANyone any idea whats the problem with this. It fails as soon as it tried to export the tables. > >Martin > > > >Public Sub createtemplate() > > Dim db As Database > Dim doc As Document > Dim conn As Container > Dim strPath As String > Dim I As Integer > Set db = CurrentDb() > strPath = "C:\forms\" > 'Export the forms > Set conn = db.Containers("Forms") > For Each doc In conn.Documents > Application.SaveAsText acForm, doc.Name, strPath & "Form_" & doc.Name & ".txt " > Next doc > 'Export the Rreports > Set conn = db.Containers("Reports") > For Each doc In conn.Documents > Application.SaveAsText acReport, doc.Name, strPath & "Report_" & doc.Name & ".txt" > Next doc > Set conn = db.Containers("Modules") > For Each doc In conn.Documents > Application.SaveAsText acModule, doc.Name, strPath & "Module_" & doc.Name & ".txt" > Next doc >For Each td In db.TableDefs > If Left(td.Name, 4) <> "MSys" Then > DoCmd.TransferText , acExportDelim, , tb.Name, strPath & "Table " & td.Name & "text", True > End If >Next td >For I = 0 To dbs.QueryDefs.Count - 1 > Application.SaveAsText acQuery, dbs.QueryDefs(I).Name, "strPath" & dbs.QueryDefs(I).Name & ".txt" >Next I > > Set db = Nothing > Set conn = Nothing > Set doc = Nothing >Exit_createtemplate: > Exit Sub > >End Sub > >Martin WP Reid >Training and Assessment Unit >Riddle Hall >Belfast > >tel: 02890 974477 > > > >------------------------------------------------------------------------ > >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.432 / Virus Database: 268.16.0/610 - Release Date: 30/12/2006 2:59 PM > > -- Marty Connelly Victoria, B.C. Canada