Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save a word file to a table.

Status
Not open for further replies.

dannyherrera

Programmer
Sep 8, 2004
6
0
0
US
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
 
I don't know exactly how to do store a Word doc in an OLE-type field, but Google does:


It looks like you're using the wrong (programmatic) approach. Use the OLE field's OLE-specific methods to "grab" the Word file instead of trying to "push" the Word file into the OLE field. You see what I'm saying?


Pete
 
i dont understand what you mean. i couldnt find anything on google
 
In your table you could drag and drop a word doc into a OLE field

Hope this helps
Hymn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top