Function upload multi attchements

Asked

Viewed 48 times

0

I’m trying to create a function to upload multiple files at the same time but even with one get an error. What I might be programming wrong?

'FILE DIALOG OPENS UPLOAD PANEL
Private Sub Comando715_Click()
Call Selectfile
End Sub

The function created is the following:

Public Function Selectfile() As String
Dim Fd As FileDialog
Set Fd = Application.FileDialog(msoFileDialogOpen)
With Fd
.AllowMultiSelect = False
.Title = "Por favor selecione as fotos desta peça a anexar"
If .Show = True Then
    Selectfile = .SelectedItems(1)
    Me.Anexo412 = Selectfile
Else
    Exit Function
End If
Set Fd = Nothing
End With
End Function

The error you give me in VBA is in the following line

Dim Fd As FileDialog

Someone can help me complete the code?

1 answer

0

The obejeto FileDialog is provided by the library Microsoft Office [Nº da versão] Object Library. Probably the reference has not been defined or is corrupted.

To activate:

Editor VBA > Ferramentas > Referências

And mark the library.

  • It solved these problems however it appears another error that I put here. Me.Anexo412 = Selectfile The specified error is: Error in '438 run time': The object does not accept this property or method

  • The file I’m trying to click on Anexo412 is a file .jpeg, how can I restrict the type of files I can select, so do not select files of types that are inappropriate?

  • You need to add the selected attachment to some obejto property Anexo412. Complete list of properties here. It’s probably the FilelName. Would look like this: Me.Anexo412.FileName = Selectfile

  • Thank you for already exporting to the defined field. The current code is:

  • @ Lúcio Rubens 'FILE DIALOG OPENS UPLOAD PANEL Private Sub Command 715_click() Call Selectfile End Sub 'FUNCTION CHECKBOX Public Function Selectfile() As String Dim Fd AsFile Dim Filter AsFiledialog Set Fd = Application.Filedialog(msoFileDialogOpen) With Fd 'IMAGE FILTER Set Filter = . Filters With Filter . Clear . Add "Images", ".jpeg;.jpg" End With 'DO NOT ALLOW MULTI-SELITITION . Allowmultiselect = False 'DEFINE THE NAME OF THE CHECKBOX . Title = " Please enter the photos from the piece" If . Show = True Then

  • This is the rest of the code; 'ATTACHMENT CODE ON FORM Selectfile = . Selecteditems(1) Me.Attachment412.Defaultpicture = Selectfile Else Msgbox "You clicked the cancel button when choosing image." Exit Function End If Set Fd = Nothing End With End Function

  • I wonder if it can help me to make this function support multi selection and load up to 8 attachments with the same function. Only that small detail is missing to resolve my question.

  • The ideal is for you to create a new question by posting your current code.. Because the question of this question was about the error in the object. @Fredericooliveira

  • And please mark as "accepted" the answer, to help other users with the same problem!

  • How do I "accept the answer"?

  • Make a tour to understand how Stackoverflow works. But to accept just click on the icon next to the answer

  • (http://answall.com/questions/72684/carregar-multi-attachements-em-varios-anexos-em-formul%C3%A1rio)

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.