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

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


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

المثال به عدد 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...

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