Hallo, hab hier etwas in VBA programmiert, aber wenn ich das ausführe bekomme ich immer die Fehlermeldung „Typen unverträglich“…
Hat jm ne Idee? Hier is mein Quelltext:
Public Sub Stop_Loss()
Dim Spalte As Single, Zeile As Single
For Spalte = 6 To 6
For Zeile = 19 To 30
With Worksheets(„Tabelle1“).Cells(Zeile, Spalte)
If .Value = 1 Then Call Email
End With
Next Zeile
Next Spalte
End Sub
Public Sub Email()
Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject(„Outlook.Application“)
Set objMail = objOutlook.CreateItem(0)
With objMail
.SentOnBehalfOfName = „xxx“
.To = „xxx“
.Subject = "Wichtige Preisänderung " & CStr(Date)
.HTMLBody = RangeToHTML(ActiveSheet, ActiveSheet.Cells(„G19:open_mouth:19“))
.Send '.display
End With
Set objMail = Nothing
Set objOutlook = Nothing
End Sub
Private Function RangeToHTML(objSheet As Worksheet, objRange As Range) As String
Dim strFilename As String
strFilename = Environ$(„TEMP“) & „/“ & Format(Now, „dd-mm-yyyy_hh-mm-ss“) & „.htm“
ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=strFilename, _
Sheet:=objSheet.Name, _
Source:=objRange.Address, _
HtmlType:=xlHtmlStatic).Publish True
RangeToHTML = CreateObject(„Scripting.FileSystemObject“). _
GetFile(strFilename).OpenAsTextStream(1, -2).ReadAll
Kill strFilename
End Function
Danke im Vorraus