Public Function barnaExcelFile(sXlsFile As String)
Dim fso As Object
Dim fldrname As String
Dim fldrpath As String
Set fso = CreateObject("scripting.filesystemobject")
fldrname = [text3]
fldrpath = CurrentProject.Path & "\السجل الالكتروني\" & fldrname
If Not fso.FolderExists(fldrpath) Then
fso.createfolder (fldrpath)
End If
Dim LExcelOriginal As String
Dim LExcelCopyOf As String
LExcelOriginal = sXlsFile
LExcelCopyOf = CurrentProject.Path & "\السجل الالكتروني\" & [text3] & "\" & [Forms]![FORM2]![text2] & "_..xlsm"
FileCopy LExcelOriginal, LExcelCopyOf
Dim db1 As DAO.Database
Dim Rst1 As DAO.Recordset
Set db1 = CurrentDb
Dim objExcel As Object
Dim objWorkbook As Object
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(LExcelCopyOf)
Set Rst1 = db1.OpenRecordset("temp", dbOpenSnapshot)
objWorkbook.Sheets(2).range("H1").Value = "اسماء طلاب الصف " & "(" & [Forms]![FORM2]![text1] & ")" & " -- " & "(" & [Forms]![FORM2]![text2] & ")" & " المادة " & "(" & [Forms]![FORM2]![text3] & ")"
With Rst1
If .RecordCount <> 0 Then
.MoveFirst
objWorkbook.Sheets(2).range("b5").CopyFromRecordset Rst1
objWorkbook.Sheets(2).range("b5").Select
End If
End With
objExcel.DisplayAlerts = True
objWorkbook.Close SaveChanges:=True
Set objWorkbook = Nothing
objExcel.Quit
Set objExcel = Nothing
Set Rst1 = Nothing
Set db1 = Nothing
VBA.Shell "Explorer.exe " & Chr(34) & LExcelCopyOf & Chr(34), vbNormalFocus
DoCmd.DeleteObject acTable, "temp"
End Function
@د.كاف يار
هل هذا صحيح ؟؟