J
Jim
I’m working on adding the functionality to create/email an access report in
pdf. I found a solution by Stephen Lebans but it requires 2 dlls in the
folder where the application resides. Since the access application is
emailed to several remote users it is easiest if the application is
self-contained. What I want to do is store the dlls in the database and
write them to the folder where the database resides when the reports form is
loaded. What I have done so far is create a table with two columns
Name(string) PK, SystemFile(OLE Object). The Name column contains two rows,
dynapdf.dll and strstorage.dll and the SystemFile contains the dlls that were
copy/paste into the field in datasheet view. Not sure if this is important
but, when I view the table in datasheet view SystemFile says “Packageâ€.
Note: If I copy/paste the files from datasheet view to the file system it
works fine.
I’ve created a test form (frmCreateFiles) that has a control for the two
fields, txt_Name (text box) and SystemFile (Bound Object Frame). The code
for the test for button is below. The files are created but the problem is
that 1k is being added to the file size which causes the pdf conversion
module to fail.
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim a() As Byte
Dim lTemp As Long
Dim sl As String
Dim db As Database
Dim varPath, varFileName As String
Dim varFileFound, varLoopCounter, i As Integer
Set db = CurrentDb
varPath = getpath(db.Name)
varLoopCounter = DCount("[Object]", "tblVersionControl", "[Object] like
'*pdf*'")
For i = 1 To varLoopCounter Step 1
varFileName = Forms!frmCreateFiles!txt_Name.Value
varFileFound = Len(Dir(varPath & varFileName))
'delete the file if it already exists
If varFileFound <> 0 Then
Kill varPath & varFileName
End If
lTemp = LenB([Forms]![frmCreateFiles]![txt_SystemFile])
ReDim a(0 To lTemp) ' should be -1
' Copy the contents of the OLE field to our byte array
a = [Forms]![frmCreateFiles]![txt_SystemFile]
sl = varPath & varFileName
Open sl For Binary Access Write As #1
Put #1, , a
Close #1
DoCmd.RunCommand acCmdRecordsGoToNext
Next i
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
pdf. I found a solution by Stephen Lebans but it requires 2 dlls in the
folder where the application resides. Since the access application is
emailed to several remote users it is easiest if the application is
self-contained. What I want to do is store the dlls in the database and
write them to the folder where the database resides when the reports form is
loaded. What I have done so far is create a table with two columns
Name(string) PK, SystemFile(OLE Object). The Name column contains two rows,
dynapdf.dll and strstorage.dll and the SystemFile contains the dlls that were
copy/paste into the field in datasheet view. Not sure if this is important
but, when I view the table in datasheet view SystemFile says “Packageâ€.
Note: If I copy/paste the files from datasheet view to the file system it
works fine.
I’ve created a test form (frmCreateFiles) that has a control for the two
fields, txt_Name (text box) and SystemFile (Bound Object Frame). The code
for the test for button is below. The files are created but the problem is
that 1k is being added to the file size which causes the pdf conversion
module to fail.
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim a() As Byte
Dim lTemp As Long
Dim sl As String
Dim db As Database
Dim varPath, varFileName As String
Dim varFileFound, varLoopCounter, i As Integer
Set db = CurrentDb
varPath = getpath(db.Name)
varLoopCounter = DCount("[Object]", "tblVersionControl", "[Object] like
'*pdf*'")
For i = 1 To varLoopCounter Step 1
varFileName = Forms!frmCreateFiles!txt_Name.Value
varFileFound = Len(Dir(varPath & varFileName))
'delete the file if it already exists
If varFileFound <> 0 Then
Kill varPath & varFileName
End If
lTemp = LenB([Forms]![frmCreateFiles]![txt_SystemFile])
ReDim a(0 To lTemp) ' should be -1
' Copy the contents of the OLE field to our byte array
a = [Forms]![frmCreateFiles]![txt_SystemFile]
sl = varPath & varFileName
Open sl For Binary Access Write As #1
Put #1, , a
Close #1
DoCmd.RunCommand acCmdRecordsGoToNext
Next i
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click