Thema Datum  Von Nutzer Rating
Antwort
31.03.2011 22:27:00 vo
****
NotSolved
01.04.2011 04:01:03 Severus
*****
NotSolved
01.04.2011 13:59:05 Vo
NotSolved
01.04.2011 14:01:41 vo
NotSolved
01.04.2011 15:55:27 Severus
*****
NotSolved
01.04.2011 20:26:02 Vo
NotSolved
02.04.2011 04:56:13 Severus
*****
NotSolved
03.04.2011 18:21:45 vo
NotSolved
03.04.2011 20:21:26 Severus
*****
NotSolved
05.04.2011 12:12:44 vo
NotSolved
04.04.2011 02:28:54 Severus
*****
NotSolved
05.04.2011 09:21:38 vo
NotSolved
05.04.2011 09:21:40 vo
NotSolved
05.04.2011 09:54:30 Severus
*****
NotSolved
05.04.2011 10:14:00 vo
NotSolved
05.04.2011 10:01:35 vo
NotSolved
05.04.2011 10:34:03 Severus
*****
NotSolved
05.04.2011 11:16:23 Vo
NotSolved
Rot Word Commandbutton Dokumentschreibgeschützt machen
05.04.2011 11:29:52 Severus
*****
NotSolved
05.04.2011 12:20:57 vo
NotSolved
05.04.2011 12:49:28 Serverus
*****
NotSolved
05.04.2011 14:07:49 vo
NotSolved
05.04.2011 14:55:54 Severus
*****
NotSolved
06.04.2011 09:13:27 Vo
NotSolved
06.04.2011 10:26:27 Vo
NotSolved
06.04.2011 11:48:31 Vo
NotSolved
06.04.2011 15:51:07 Severus
NotSolved
06.04.2011 16:24:12 Severus
NotSolved
07.04.2011 14:36:02 vo
NotSolved
07.04.2011 16:43:49 Severus
NotSolved
07.04.2011 17:56:00 Severus
NotSolved
07.04.2011 20:13:08 Vo
NotSolved
08.04.2011 11:28:17 Vo
Solved
12.04.2011 15:10:58 vo
NotSolved
12.04.2011 16:13:51 Severus
NotSolved
13.04.2011 14:46:35 vo
NotSolved
13.04.2011 16:58:12 Severus
NotSolved
15.04.2011 13:14:03 vo
Solved

Ansicht des Beitrags:
Von:
Severus
Datum:
05.04.2011 11:29:52
Views:
2423
Rating: Antwort:
  Ja
Thema:
Word Commandbutton Dokumentschreibgeschützt machen

Hier nochmal mein Code. Bis auf das eigentliche Versenden der Mail ist es getestet. Der Mailversand kann bei mir nicht getestet werden, weil ich kein Outlook verwende. Vorausetzung: Zwei VommandButtons mit dem Namen (NICHT Caption) CommandButton1 und CommandButton2. Wenn die Buttons andere Namen haben, muß die jeweilige Prozedur von "CommanButtonx_Click()" in "Name_Click()" geändert werden. Der letzte von Dir genannte Fehler beruht auf einer bei Dir fehlenden Deklaration der Variablen "Start". Bei mir ist sie deklariert. Wieso die Deklaration nicht mit übertragen wurde ist mir schleierhaft.

Option Explicit

Private Sub CommandButton1_Click()
Dim strEmailAdr As String
strEmailAdr = InputBox("Emailadresse des Empfängers eingeben:", "Mailadresse")
If InStr(1, strEmailAdr, "@", vbBinaryCompare) = 0 Or InStr(1, strEmailAdr, ".", vbBinaryCompare) = 0 Then
    MsgBox """" & strEmailAdr & """ ist keine Emailadresse!" & Chr(10) _
    & "Geben Sie eine gültige Emailadresse ein!", vbCritical, "Abbruch..."
    Exit Sub
End If
'Wenn auf diesem CodeModule vor der (jetzigen) Zeile 33: strEmailAdr = "" Code eingefügt wird muß in der folgenden
'Zeile die Zeilennummer 33 bei .ReplaceLine = 33 angepaßt werden!
ThisDocument.VBProject.VBComponents("ThisDocument").CodeModule.ReplaceLine 33, "strEmailAdr = """ & strEmailAdr & """"
ThisDocument.VBProject.VBComponents("ThisDocument").CodeModule.DeleteLines 2, 23
With ThisDocument.CommandButton1
    .Width = 0
    .Height = 0
    .ForeColor = &HFFFFFF
    .BackColor = &HFFFFFF
    .Enabled = False
End With
ThisDocument.Protect wdAllowOnlyReading, , strEmailAdr
ThisDocument.Save
End Sub

Private Sub CommandButton2_Click()
'Es muß ein Verweis auf das "Microsoft Outlook nn.n Object Library" gesetzt sein!
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim olRun As Boolean
Dim strEmailAdr As String
Dim Start As Single
strEmailAdr = ""
On Error Resume Next
If strEmailAdr = "" Then
    MsgBox "Wegen fehlender Emailadresse kann keine Antwortmail versandt werden!", vbCritical, "Abbruch..."
    Exit Sub
End If
olRun = True
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
    Err.Clear
    Set olApp = CreateObject("Outlook.Application"): DoEvents
    Start = Timer
    While Timer < Start + 5
        DoEvents
    Wend
    olRun = False
End If

Set olMail = olApp.CreateItem(0)
With olMail
    'Die Angaben für "Subject" und "body" müssen natürlich angepaßt werden!
    .Recipients.Add strEmailAdr
    .Subject = "Rückmeldung"
    .body = "Ihre Mail bezüglich der ausstehenden Lieferung ist hier eingegangen und wurde bearbeitet."
    .send
End With
Set olMail = Nothing
If olRun = False Then
    olApp.Quit: DoEvents
    Start = Timer
    While Timer < Start + 5
        DoEvents
    Wend
End If
Set olApp = Nothing
End Sub


 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
31.03.2011 22:27:00 vo
****
NotSolved
01.04.2011 04:01:03 Severus
*****
NotSolved
01.04.2011 13:59:05 Vo
NotSolved
01.04.2011 14:01:41 vo
NotSolved
01.04.2011 15:55:27 Severus
*****
NotSolved
01.04.2011 20:26:02 Vo
NotSolved
02.04.2011 04:56:13 Severus
*****
NotSolved
03.04.2011 18:21:45 vo
NotSolved
03.04.2011 20:21:26 Severus
*****
NotSolved
05.04.2011 12:12:44 vo
NotSolved
04.04.2011 02:28:54 Severus
*****
NotSolved
05.04.2011 09:21:38 vo
NotSolved
05.04.2011 09:21:40 vo
NotSolved
05.04.2011 09:54:30 Severus
*****
NotSolved
05.04.2011 10:14:00 vo
NotSolved
05.04.2011 10:01:35 vo
NotSolved
05.04.2011 10:34:03 Severus
*****
NotSolved
05.04.2011 11:16:23 Vo
NotSolved
Rot Word Commandbutton Dokumentschreibgeschützt machen
05.04.2011 11:29:52 Severus
*****
NotSolved
05.04.2011 12:20:57 vo
NotSolved
05.04.2011 12:49:28 Serverus
*****
NotSolved
05.04.2011 14:07:49 vo
NotSolved
05.04.2011 14:55:54 Severus
*****
NotSolved
06.04.2011 09:13:27 Vo
NotSolved
06.04.2011 10:26:27 Vo
NotSolved
06.04.2011 11:48:31 Vo
NotSolved
06.04.2011 15:51:07 Severus
NotSolved
06.04.2011 16:24:12 Severus
NotSolved
07.04.2011 14:36:02 vo
NotSolved
07.04.2011 16:43:49 Severus
NotSolved
07.04.2011 17:56:00 Severus
NotSolved
07.04.2011 20:13:08 Vo
NotSolved
08.04.2011 11:28:17 Vo
Solved
12.04.2011 15:10:58 vo
NotSolved
12.04.2011 16:13:51 Severus
NotSolved
13.04.2011 14:46:35 vo
NotSolved
13.04.2011 16:58:12 Severus
NotSolved
15.04.2011 13:14:03 vo
Solved