اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

كود لحذف الاسطر 3 الاولى من شيت اكسل بالأكسس


SABER_EDP

الردود الموصى بها

انا لا استطيع  ارفاق الملف لحساسية البيانات  لكن الموضوع باختصار

انا احول تقارير من الاوراكل بصيغة csv

,واحولها  الى صيغة xls

وبعد  ذلك  اقوم بربطها  مع قاعدة بيانات  اكسس  بعد حذف الاسطر الاولى 3 الثلاثة 

فهل من طريقة للتعامل مع ملف الاكسيل  برمجيا  بحذف  3 اسطر بمجرد ربط الشيت مع الاكسس او قبل ربطة  بة

 

رابط هذا التعليق
شارك

السلام عليكم

اشكر الاخ جعفر على اهتمامة

المطلوب: تحويل ملف اسمة saber.csv  الى ملف saber.xlsبعد حذف الاسطر الثلاثة الاولى  برمجيا

بواسطة الاكسس قبل استيرادة او ربطة بقاعدة البيانات

السطر الاول لا يحتوى على اسماء الاعمدة

اسماء الاعمدة فى السطر 4

اخوكم صابر

رابط هذا التعليق
شارك

تفضل أخي صابر :rol:

 

انت تختار الملف ، ويقوم الكود بالباقي :rol:

الكود هو:


    Dim TextLine, File_Name, File_ext, Folder_Name, nFile_Name
    
    File_Name = Dir(Me.txtPath)                             'the file name only
    File_ext = Mid(File_Name, InStrRev(File_Name, ".") + 1) 'the file extension
    Folder_Name = Replace(Me.txtPath, File_Name, "")        'the folder name
    
    'a temp csv file to transfer to it the correct lines
    nFile_Name = Folder_Name & Mid(File_Name, 1, Len(File_Name) - Len(File_ext) - 1) & "_2." & File_ext
    
    'open both Input and Output files
    Open Me.txtPath For Input As #1
    Open nFile_Name For Output As #2
    
    i = 0
    Do While Not EOF(1)    ' Loop until end of file.
        Line Input #1, TextLine    ' Read line into variable.
        i = i + 1
        
        'skip the 1st 3 lines, and write the rest
        If i >= 4 Then
            Print #2, TextLine
        End If
        
    Loop
    
    Close #1
    Close #2
    
    
    'now we have a csv file correctly saved,
    'convert it to xls
    
    'make reference to Microsoft Excel xx.x object Library
    
    Dim wBook As workbook
    
    Set wBook = Workbooks.Open(nFile_Name, Format:=6, Delimiter:=",")
    wBook.SaveAs Replace(Me.txtPath, ".csv", ".xls"), FileFormat:=xlExcel8
    wBook.Close False
    
    'delete the temp cvs file
    Kill nFile_Name

 

 

جعفر

 

298.Remove_3_Lines_csv.mdb.zip

  • Like 1
رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information