kloosterofobie
Gebruiker
- Lid geworden
- 12 sep 2005
- Berichten
- 126
Ik ben bezig met de tool van Ron de Bruin om een excelbestand te verzenden vanuit Excel.
De tool werkt goed alleen ik wil wat kleine dingen aanpassen. In mijn excel bestand moet men hun naam invullen. Nu wil ik de naam terug laten komen in het excelbestand.
Ben zelf al een beetje wezen kijken en proberen maar kom er niet uit.
Het gaat fout bij het rode deel
Sub Mail_Workbook_2()
'Working in 2000-2007
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Set wb1 = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "& wb1.Name & Sheets("Blad1").Range("C7") & " " & Format(Now, "dd-mmm-yy")
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))
wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)
With wb2
On Error Resume Next
.SendMail "jeroen.klooster@quicknet.nl", _
"Inschrijving EK Pool 2008"
On Error GoTo 0
.Close SaveChanges:=False
End With
'Delete the file
Kill TempFilePath & TempFileName & FileExtStr
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Heeft iemand een oplossing??
De tool werkt goed alleen ik wil wat kleine dingen aanpassen. In mijn excel bestand moet men hun naam invullen. Nu wil ik de naam terug laten komen in het excelbestand.
Ben zelf al een beetje wezen kijken en proberen maar kom er niet uit.
Het gaat fout bij het rode deel
Sub Mail_Workbook_2()
'Working in 2000-2007
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Set wb1 = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Make a copy of the file/Open it/Mail it/Delete it
'If you want to change the file name then change only TempFileName
TempFilePath = Environ$("temp") & "\"
TempFileName = "& wb1.Name & Sheets("Blad1").Range("C7") & " " & Format(Now, "dd-mmm-yy")
FileExtStr = "." & LCase(Right(wb1.Name, Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))
wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)
With wb2
On Error Resume Next
.SendMail "jeroen.klooster@quicknet.nl", _
"Inschrijving EK Pool 2008"
On Error GoTo 0
.Close SaveChanges:=False
End With
'Delete the file
Kill TempFilePath & TempFileName & FileExtStr
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Heeft iemand een oplossing??