hab hier zwei funktionierende scripts. eins macht einen screenshot und speichert es als gif und das andere versendet eine datei per email.
ich möchte nun diese beiden scripts zusammenführen. die variabel aus dem bildscript soll an das andere script zum attach übergeben werden.
-----------
Public Sub GIF_Snapshot()
Dim varReturn As Variant
Dim MyAddress As String
Dim SaveName As Variant
Dim MySuggest As String
Dim Hi As Integer
Dim Wi As Integer
Dim Suffiks As Long
Set Sourcebok = ActiveWorkbook
MySuggest = sShortname(ActiveSheet.Name)
ImageContainer_init
Sourcebok.Activate
MyAddress = SelectArea
If MyAddress <> "A1" Then
SaveName = Application.GetSaveAsFilename( _
InitialFileName:=MySuggest _
& ".gif", fileFilter:="Gif Files (*.gif), *.gif")
Range(MyAddress).Select
Selection.CopyPicture Appearance:=xlScreen, _
Format:=xlBitmap
If SaveName = False Then
GoTo Avbryt
End If
If InStr(SaveName, ".") Then SaveName _
= Left(SaveName, InStr(SaveName, ".") - 1)
Selection.CopyPicture Appearance:=xlScreen, _
Format:=xlBitmap
Hi = Selection.Height + 0 'adjustment for gridlines
Wi = Selection.Width + 2 'adjustment for gridlines
containerbok.Activate
ActiveSheet.ChartObjects(1).Activate
MakeAndSizeChart ih:=Hi, iv:=Wi
ActiveChart.Paste
ActiveChart.Export Filename:=LCase(SaveName) & _
".gif", FilterName:="GIF"
ActiveChart.Pictures(1).Delete
Sourcebok.Activate
End If
Avbryt:
On Error Resume Next
Application.StatusBar = False
containerbok.Saved = True
containerbok.Close
End Sub
----------------------
Sub email_versenden()
Dim olApp As Outlook.Application
Dim myMail As MailItem
Set olApp = CreateObject("Outlook.Application")
Set myMail = olApp.CreateItem(olMailItem)
With myMail
.Recipients.Add "morgano@gmx.net"
.Attachments.Add "e:\test.gif"
.Subject = "Kostenvoranschlag"
.Body = "Guten Tag, " & vbCr & vbCr
.DeleteAfterSubmit = True
.Send
End With
End Sub
attachment.add soll nun also die variable savename erhalten.
am besten ist natürlich das ganze script oben einzubaun, doch sind alle versuche gescheitert bisher