[AccessD] SaveAsText, LoadFromText (was: URGENT!! A2K - form won't load; is code lost??)

MartyConnelly martyconnelly at shaw.ca
Mon Jul 26 20:55:16 CDT 2004


I had a closer look at the code

This doesn't seem to work with tables.
SaveAsText 0,"Products","C:\Program Files\Microsoft 
Office\Office\Samples\Northwind_BackUp.mdb"

This doesn't seem to work with certain queries if you are scanning 
through all the document names.
SaveAsText 1,"Products","C:\Program Files\Microsoft 
Office\Office\Samples\Northwind_BackUp.mdb"

However this method below  entering the table name by grabbing it from 
document containers from within NorthWind works.
It must have something to do with LPSTR or BSTR strings, I tried fiddling
with various methods to get it to accept a C like null terminated 
string, nothing seemed to work

This piece of code copies the queries but it fails with the on error 
resume statement so it skips the garbled  table names.

Sub testit()
Dim con As Container
Dim doc As Document
Set con = DBEngine(0)(0).Containers("Tables")

       With con
           For Each doc In .Documents
               With doc
                
                   On Error Resume Next
                   SaveAsText 1, .Name, "C:\Program Files\Microsoft 
Office\Office\Samples\TextDump_" &.name & ".txt"
                   Debug.Print "*" & .Name & "*"
                  
                   On Error GoTo 0
                
               End With
           Next doc
       End With

End Sub

Where the tables and relationships are copied is; in this even deeper 
undocumented  call in the code
 SaveAsText 6, "", bck

Which stand alone would look like this.
 SaveAsText 6,"", "C:\Program Files\Microsoft 
Office\Office\Samples\TextDump2.mdb"

LoadFromText/SaveAsText are undocumented methods used by VSS integration.
The "6" param copies the "ACB" portion that is checked in.... it includes
project refs, tables, relationships, commandbars, and import specs.


Gustav Brock wrote:

>Great Marty!
>
>But are you sure it will save everything?
>
>If I try acTable it won't - error 2487, object type is empty or
>invalid for this method or action.
>
>/gustav
>
>
>  
>
>>hmm.. I never thought of attaching  form code to a newsgroup message 
>>this way.
>>It would show the design quite easily
>>    
>>
>
>  
>
>>However you might find this useful as it uses same method.
>>    
>>
>
>  
>
>> Here is the method to dump everything in an mdb to text files in temp
>>directory via saveastext--loadfromtext method into a new mdb and then
>>compile it.
>>    
>>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list