Saving a .doc file to a table

  • Thread starter Thread starter dherrera
  • Start date Start date
D

dherrera

Guest
i want to be able to save a .doc file to one of my tables. i have a quote system where the user can export a quote to word and update it. i want them to be able to upload the new revised quote file to the table. i have set up the table to accespt ole objects and have created a form that allows the user to select to file to upload from their computer. the following is the code i have so far but doesnt work.

Code:
Private Sub cmdSaveUpload_Click()
On Error GoTo Err_cmdSaveUpload_Click

<this line of code gives the error: "The command or action InsertObject isnt available right now.">
'DoCmd.RunCommand acCmdInsertObject

<this line of code gives the error: "You cannot import this file.">    
DoCmd.TransferText acImportDelim, "Revised Quote", "tblUploadedQuotes", Me.txtUpload.Value

Exit_cmdSaveUpload_Click:
    Exit Sub

Err_cmdSaveUpload_Click:
    MsgBox Err.Description
    Resume Exit_cmdSaveUpload_Click
    
End Sub

Private Sub cmdUpload_Click()
    
    Dim fd As FileDialog

    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    Dim vrtSelectedItem As Variant

    'Use a With...End With block to reference the FileDialog object.
    With fd

        'Allow the user to select multiple files.
        .AllowMultiSelect = False

        'Use the Show method to display the File Picker dialog box and return the user's action.
        'If the user presses the action button...
        If .Show = -1 Then
            'Step through each string in the FileDialogSelectedItems collection.
            For Each vrtSelectedItem In .SelectedItems

                'vrtSelectedItem is a String that contains the path of each selected item.
                'You can use any file I/O functions that you want to work with this path.
                'This example simply displays the path in a message box.
                Me.txtUpload = vrtSelectedItem

            Next
        'If the user presses Cancel...
        Else
        End If
    End With

    'Set the object variable to Nothing.
    Set fd = Nothing

End Sub
 
Try this...

Private Sub Command1_Click()
On Error GoTo errCommand1

Screen.PreviousControl.SetFocus
RunCommand acCmdInsertObject
Exit Sub

errCommand1:
Select Case Err
Case 2046
MsgBox "OLE field must be selected before running this procedure.", vbCritical, "Not Available"
Case 2501
'Cancel selected in dialog box - do nothing
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select
End Sub


HTH :cool:
 

Users who are viewing this thread

Back
Top Bottom