P
Phil Stokes
I have been trying to copy a file using the following code but it gives the
error
Error '438'
Object doesn't support this property or method
Code below
Dim UpdateTimeElement(0 To 3) As String
Dim Network_path, local_path
Public Sub main() '(UpdateTimeElement)
Call GetNetworkPath.main(Network_path, local_path)
Dim FileNameArray As Variant
Dim ProdNumArray As Variant
Dim outMessage As String
Dim oOutlook As New outlook.Application
Dim oMessage As outlook.MailItem
Dim FileNumber As Integer
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
FileNameArray = Array("0021", "0003", "0017", "0045")
Set oMessage = oOutlook.CreateItem(olMailItem)
With oMessage
.To = some email address
.Subject = Format(Now(), "hhmm ddd, dd-mmm-yyyy")
For i = 0 To 3
Set fs = Application.FileSearch
With fs
.LookIn = "z:\" + FileNameArray(i) + "\"
.filename = "z:\" + FileNameArray(i) + "\" +
FileNameArray(i) + ".1"
If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
filename = "z:\" + FileNameArray(i) + "\" +
FileNameArray(i) + ".1"
fs.CopyFile filename, "c:\temp"
Else
filename = "z:\" + FileNameArray(i) + "\" +
FileNameArray(i) + ".2"
End If
End With
.Attachments.Add filename, olByValue, 1, FileNameArray(i) +
".tif"
Next i
.body = outMessage
.Display
End With
End Sub
I dont know if i'm just not understning how to use this FleSystemObject
initially I just had
FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"
in the code but it didn't work either. should I declare someting for this
to work.
I think i really need some help
Phil
error
Error '438'
Object doesn't support this property or method
Code below
Dim UpdateTimeElement(0 To 3) As String
Dim Network_path, local_path
Public Sub main() '(UpdateTimeElement)
Call GetNetworkPath.main(Network_path, local_path)
Dim FileNameArray As Variant
Dim ProdNumArray As Variant
Dim outMessage As String
Dim oOutlook As New outlook.Application
Dim oMessage As outlook.MailItem
Dim FileNumber As Integer
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
FileNameArray = Array("0021", "0003", "0017", "0045")
Set oMessage = oOutlook.CreateItem(olMailItem)
With oMessage
.To = some email address
.Subject = Format(Now(), "hhmm ddd, dd-mmm-yyyy")
For i = 0 To 3
Set fs = Application.FileSearch
With fs
.LookIn = "z:\" + FileNameArray(i) + "\"
.filename = "z:\" + FileNameArray(i) + "\" +
FileNameArray(i) + ".1"
If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
filename = "z:\" + FileNameArray(i) + "\" +
FileNameArray(i) + ".1"
fs.CopyFile filename, "c:\temp"
Else
filename = "z:\" + FileNameArray(i) + "\" +
FileNameArray(i) + ".2"
End If
End With
.Attachments.Add filename, olByValue, 1, FileNameArray(i) +
".tif"
Next i
.body = outMessage
.Display
End With
End Sub
I dont know if i'm just not understning how to use this FleSystemObject
initially I just had
FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"
in the code but it didn't work either. should I declare someting for this
to work.
I think i really need some help
Phil