Hello Jialiang Ge
Thank you for your quick reply.
I have been trying to fully convert everything, so;
Access 2003 (mdb) has been converted to Access 2007 (accdb)
The Word document have been converted from DOC to DOCX, and the
document opens OK from Windows Explorer.
The code for loading the document into the database is located in a module
in the database itself, and looks like this:
+++++ Start code +++++
Private Sub SaveToDB()
Dim db As Database
Dim rs As Recordset2
Dim bytBLOB() As Byte
Dim strImagePath As String
Dim intNum As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT fldReportfile FROM tblSystem")
If rs.RecordCount > 0 Then
strImagePath = "C:\Temp\Report.docx"
With rs
intNum = FreeFile
Open strImagePath For Binary As #intNum
ReDim bytBLOB(FileLen(strImagePath))
Get #intNum, , bytBLOB
Close #1
.Edit
.Fields(0).AppendChunk bytBLOB
.Update
End With
End If
rs.Close
Set db = Nothing
End Sub
+++++ End code +++++
References in the database is to ADODB version 2.8 and Access 12 Object
library along with some others non database references.
The code to save the document to a file from the database in the VB6 COM
Addin looks like this:
+++++ Start code +++++
BlockSize = 50
cm.CommandText = "SELECT fldReportfile FROM tblSystem"
rs.Open cm, , adOpenDynamic, adLockReadOnly
If Not rs.BOF And Not rs.EOF Then
If rs("fldReportfile").ActualSize > 0 Then
file_name = repPath & "\Office Installationreport.docx"
On Error Resume Next
Kill file_name
On Error GoTo CreateReportError
file_num = FreeFile
Open file_name For Binary As #file_num
file_length = rs("fldReportfile").ActualSize
If file_length > 0 Then
num_blocks = file_length / BlockSize
left_over = file_length Mod BlockSize
For block_num = 1 To num_blocks
bytes() = rs("fldReportfile").GetChunk(BlockSize)
Put #file_num, , bytes()
Next block_num
On Error Resume Next
If left_over > 0 Then
bytes() = rs("fldReportfile").GetChunk(left_over)
Put #file_num, , bytes()
End If
Else
MsgBox "Error loading report. Template is missing in the database",
vbSystemModal + vbOKOnly, App.ProductName & " Ver: " & App.Major & "." &
App.Minor & "." & App.Revision
GoTo CreateReportExit
End If
Close #file_num
DoEvents
End If
End If
rs.Close
+++++ End code +++++
Referenses int the project is to ADODB 2.8, DAO 3.6 and to Word 12 Object
Library along with some others.
The Field2 object is not availible in DAO 3.6 or ADODB 2.8, since the
reading from the table is made outside the Access database.
Hope this will get you a complete picture of the situation.
Best Regards
--
Peter Karlstr?m
Midrange AB
Sweden
"Jialiang Ge [MSFT]" said:
Hello Peter,
What's the Access version where the VB6 COM Add-in runs for the docx
files?
If it is Access 2003, as far as I know, Access 2003 does not support
Office
2007 file types in its field object. Docx is likely to be regarded as doc
file based on my tests, and an error may be popped up when users open the
file.
If it is Access 2007, have you tried the new Field object: Field2?
http://msdn.microsoft.com/en-us/library/bb257445.aspx
Access 2007 should support docx files in a good manner.
Please let me know if there's any other questions or concerns.
Regards,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
This posting is provided "AS IS" with no warranties, and confers no
rights.
=================================================