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?
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– Frederico Oliveira
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?– Frederico Oliveira
You need to add the selected attachment to some obejto property
Anexo412
. Complete list of properties here. It’s probably theFilelName
. Would look like this:Me.Anexo412.FileName = Selectfile
– Lucio Rubens
Thank you for already exporting to the defined field. The current code is:
– Frederico Oliveira
@ 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
– Frederico Oliveira
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
– Frederico Oliveira
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.
– Frederico Oliveira
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
– Lucio Rubens
And please mark as "accepted" the answer, to help other users with the same problem!
– Lucio Rubens
How do I "accept the answer"?
– Frederico Oliveira
Make a tour to understand how Stackoverflow works. But to accept just click on the icon next to the answer
– Lucio Rubens
(http://answall.com/questions/72684/carregar-multi-attachements-em-varios-anexos-em-formul%C3%A1rio)
– Frederico Oliveira