我正在尝试制作一个脚本,通过发送邮件将我的个人照片上传到Flickr。完整的脚本可以在这里找到:http://pastebin.com/6pQFMZmk
我选择使用Excel作为数据库来记住以前上传过的内容;对于我需要在电子表格中搜索的每个文件,如果已经上传的话。这是通过将变量objCell
设置为find
函数的结果来完成的
这是第一次使用,但第二次设置objCell
我收到错误:runtime error: Object variable not set
代码的相关部分如下:
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
wscript.echo "VOLGENDE FOLDER"
wscript.echo ""
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
if soort.Exists(UCase(Mid(objFile.Name, InStrRev(objFile.Name,".") + 1))) Then
strSearchTerm = objFile.Name & objFile.Size & objFile.DateLastModified
msgbox strSearchTerm & " ; " & objCell & " ; " & xlFormulas & " ; " & xlPart & " ; " & xlByRows & " ; " & xlNext & " ; " & boolMatchCase
'THE LINE UNDER HERE IS THE PROBLEM
Set objCell = objWorkSheet.Cells.Find(strSearchTerm, objCell, xlFormulas,xlPart, xlByRows, xlNext, boolMatchCase)
If Not objCell Is Nothing Then
'I found it!, don't upload...
objCell = Nothing
Else
'not fout; upload
temp = upload(subfolder.path & "\" & objFile.Name)
wscript.echo String(6-len(introw)," ") & intRow & " " & Subfolder.Path & " " & objFile.Name & " ; " & Mid(Subfolder.Path, InStrRev(Subfolder.Path, "\")+1) & " ; " & UCase(Mid(objFile.Name, InStrRev(objFile.Name,".") + 1)) & " " & objFile.Size
if temp then
objExcel.Cells(intRow, 2).Value = strSearchTerm
objExcel.Cells(intRow, 1).value = Now()
Else
objExcel.Cells(intRow, 2).Value = objFile.Name
objExcel.Cells(intRow, 1).value = "upload failed"
End if
intRow = intRow + 1
End if
Else
wscript.echo objFile.name & ": " & Mid(objFile.Name, InStrRev(objFile.Name,".") + 1) & " is niet in type"
End if
Next
ShowSubFolders Subfolder
Next
End Sub
我意识到我可以使用简单的文本文件来跟踪上传;但是我已经决定使用excel;后来我打算扩展脚本,这个Excel会很方便。
答案 0 :(得分:0)
您需要Set
将一个对象(Nothing是一个对象!)分配给一个变量:
objCell = Nothing
==>
Set objCell = Nothing