اذهب الي المحتوي
أوفيسنا

كيف نقوم باخراج محتويات الاكسيل الي ملف نص


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

المثال به عدد 2 كود

الأول يقوم باخراج محتويات الثلاث خلايا الملونة بعد دمجها الي ملف نص و فتحهد

و الثاني يقوم باخراج الخلايا فى سطور مستقلة

Sub Macro2()

a = Cells(3, 2) & "," & Cells(3, 3) & "," & Cells(3, 4)

Dim Filename As String

Filename = "c:\testfile.txt"

Open Filename For Output As #1

Print #1, a

Close #1


Dim x

    x = Shell("notepad.exe c:\testfile.txt", 1)

End Sub


Sub Macro3()

a1 = Cells(3, 2)

a2 = Cells(3, 3)

a3 = Cells(3, 4)


Dim Filename As String

Filename = "c:\testfile.txt"

Open Filename For Output As #1

Print #1, a1

Print #1, a2

Print #1, a3


Close #1


Dim x

    x = Shell("notepad.exe c:\testfile.txt", 1)

End Sub
و يلاحظ وجود طريقة أخري للكتابة فى ملف نص
Sub anotherway()

Dim fs, S, A

    Set fs = CreateObject("Scripting.FileSystemObject")

    Set A = fs.CreateTextFile("c:\" & "temp.txt", True)

    A.writeline "Pivots per Sheet - in File named : " & ActiveWorkbook.FullName & " : "

    A.writeline

    A.writeline "*********** Prepared By Mohamed Taher *****************"

    A.writeline

 A.Close

    

    Dim x

    x = Shell("notepad.exe c:\temp.txt", 1)

End Sub

WriteTotext.rar

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

  • 15 years later...

من فضلك سجل دخول لتتمكن من التعليق

ستتمكن من اضافه تعليقات بعد التسجيل



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

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

Important Information