Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Access Citydesk data via MS Access


any idea how i can detach, change or export resources (images, documents etc..) if i open a citydesk file via MS Acess?

thanks for help

Tuesday, June 18, 2002

They are in there as OLE blob's (the data for the files anyway).  Here's two functions in VB that you can use to get at the data and get it into a string.

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
  pDest As Any, _
  pSrc As Any, _
  ByVal cb As Long)

Public Function GetStringFromOleField(ole As dao.Field) As String
    GetStringFromOleField = ""
    If ole.FieldSize = 0 Then Exit Function
    Dim bytes() As Byte
    bytes() = ole.GetChunk(0, ole.FieldSize)
    GetStringFromOleField = Space$(ole.FieldSize)
    CopyMemory ByVal GetStringFromOleField, bytes(0), ole.FieldSize

End Function

Public Sub GetOleFieldFromString(ole As dao.Field, sData As String)
    If Len(sData) < 1 Then
        ole.value = ""
        Dim bytes() As Byte
        ReDim bytes(Len(sData) - 1)
        CopyMemory bytes(0), ByVal sData, Len(sData)
        ole.AppendChunk bytes
    End If

End Sub

Michael H. Pryor
Wednesday, June 19, 2002

*  Recent Topics

*  Fog Creek Home