Invalid procedure call or argument

เริ่มโดย Krathok-man, 10 ก.พ 21 , 11:01:02

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

Krathok-man


Dim TextOUT  As Variant
Dim NotpadDoc
Dim Myfso As New FileSystemObject
Set NotpadDoc = Myfso.CreateTextFile("D:\Report1.txt", True)

Dim Rs   As DAO.Recordset
Set Rs = CurrentDb.OpenRecordset("select * from  report1 order by ida ")
If Rs.RecordCount > 0 Then
Do Until Rs.EOF

TextOUT = Trim(Rs("summary"))
NotpadDoc.Write TextOUT
NotpadDoc.Write Chr(13)

Rs.MoveNext
Loop


NotpadDoc.Close
Set Myfso = Nothing

    On Error Resume Next
    Shell "Notepad.exe " & "D:\Report1.txt", vbNormalFocus
    Dim oShell
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "% x"

  End If

Rs.Close
Set Rs = Nothing


Code นี้มันทำงานได้  เมื่อ TextOUT  มีค่าไม่ยาว    แต่เมื่อมันมี  ข้อความยาวขึ้น   มันก็ฟ้อง  "Invalid procedure call or argument "    ผมไปไม่เป็นเลยครับ  ไม่มี idea  ว่าจะแก้อะไรดี   ขอความเห็นจากผุ้มีประสบการณ์ หน่อยครับ  ควรทำอย่างไร
  •  
    โพสต์นี้ได้รับคำขอบคุณจาก: Jieng2021

PNR

 Dim NotpadDoc
Dim oShell

ลองแก้เป็น
Dim NotpadDoc As Object
Dim oShell As Object

Time to stop for me  :dizzy:
  •