Runtime Error 1004: PasteSpecial
Posted: Wed Sep 30, 2015 12:12 pm
อาการของ Runtime Error นี่เกิดจากอะไรหรอคะ คือ ถ้ารันแบบ Step into (F8) แล้ว รันได้แต่ถ้า รันแบบ F5 มันจะติดบรรทัด Sheets(q - 1).Range("A1").PasteSpecial xlPasteValues ตลอดเลยอ่ะค่ะ
Run-Time Error '1004':
PasteSpecial method of Range class failed
FileWord ที่นำเข้าข้อมูลมาประมาณ 455kb แต่ว่า content ข้างในค่อนข้างเยอะค่ะ
ขอบคุณมากมากนะคะ
Run-Time Error '1004':
PasteSpecial method of Range class failed
FileWord ที่นำเข้าข้อมูลมาประมาณ 455kb แต่ว่า content ข้างในค่อนข้างเยอะค่ะ
ขอบคุณมากมากนะคะ
Code: Select all
Public Sub opencsfile_1()
Dim q As Variant
Dim filename_1 As Variant
Dim Wordapp As Variant
Workbooks("ClientSegregation_Macro.xlsm").Worksheets(2).Select
Range("a1").Activate
For q = 3 To 6
Set Wordapp = CreateObject("word.Application")
filename_1 = Workbooks("ClientSegregation_Macro.xlsm").Worksheets("Path").Cells(q, 7)
Wordapp.documents.Open filename_1
Wordapp.Visible = True
Wordapp.activedocument.Range.Copy
Workbooks("ClientSegregation_Macro.xlsm").Worksheets(q - 1).Select
Sheets(q - 1).Range("A1").Activate
Sheets(q - 1).Range("A1").PasteSpecial xlPasteValues 'ERROR บรรทัดนี้ค่ะ
Wordapp.activedocument.Close
Wordapp.Quit
Set Wordapp = Nothing
Next q
End Sub