Forum Discussion

ASV's avatar
ASV
Contributor
13 years ago

Search Files



Hi 

I write this code



1.  Set objWord = CreateObject("Word.Application")


2.  Set objDoc = objWord.Documents.Add()


3.  


4.  objWord.FileSearch.FileName = "*.mp3"


5.  objWord.FileSearch.LookIn = "C:\"


6.  objWord.FileSearch.SearchSubfolders = True


7.  objWord.FileSearch.Execute


8. 

9.  Set objRange = objDoc.Range()


10.  objDoc.Tables.Add objRange, 1, 1


11.  Set objTable = objDoc.Tables(1)


12.  objTable.Range.Font.Size = 10


13.

14.  x = 1

15.  


16.  For Each objFile in objWord.FileSearch.FoundFiles

17.          If x > 1 Then


18.             objTable.Rows.Add()


19.          End If


20.         objTable.Cell(x, 1).Range.Text = objFile.name  

21.          x = x + 1


22.  Next




objDoc.SaveAs("C:\testdoc.docx")

objWord.Quit



but I have an error in line 4 "This command is not available on this platform." What to do avoid this problem.

Thanks in advance.