تفضل أخي @العنزي العنزي ، تم إجاء تعديلات على زر اختيار ملف الـ PDF ، وعلى زر الحفظ :-
في زر اختيار الملف :-
On Error GoTo err:
Dim dbox As Office.FileDialog
Set dbox = Application.FileDialog(msoFileDialogFilePicker)
With dbox
.Title = "PDF"
.Filters.Clear
.Filters.Add "PDF files", "*.PDF"
.AllowMultiSelect = False
.Show
book_Bath = .SelectedItems(1)
Me.Image1.Picture = Me.book_Bath
Me.Image1.Requery
End With
Set dbox = Nothing
err: DoCmd.CancelEvent
وفي زر الحفظ :-
If IsNull(book_Num) Then
Beep
MsgBox "رقم الكتاب مطلوب"
Exit Sub
End If
Dim targetFolder As String
If Me.book_Type = "وارد" Then
targetFolder = CurrentProject.Path & "\Files\Wared"
ElseIf Me.book_Type = "صادر" Then
targetFolder = CurrentProject.Path & "\Files\Sader"
Else
MsgBox "نوع الكتاب غير معروف"
Exit Sub
End If
If Dir(targetFolder, vbDirectory) = "" Then
MkDir targetFolder
End If
SourceFile = Me.book_Bath
strmyfile = Right(book_Bath, Len(book_Bath) - InStrRev(book_Bath, "."))
DestinationFile = targetFolder & "\" & Me.book_Num & "." & strmyfile
FileCopy SourceFile, DestinationFile
MsgBox "تم حفظ الكتاب"
Me.Requery
myArchfa.zip