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
Blau Word Commandbutton Dokumentschreibgeschützt machen
05.04.2011 11:16:23 Vo
NotSolved
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:
Vo
Datum:
05.04.2011 11:16:23
Views:
2365
Rating: Antwort:
  Ja
Thema:
Word Commandbutton Dokumentschreibgeschützt machen

Hi,

ich weiße auch nicht warum es bei mir nicht funktioniert. Bin echt verzweifelt.  Wenn ich Button1 ausführe, nach der Email-Eingabe bekomme ich immer diese Meldung: Laufzeitfehler 4198: Befehl misslungen.

Danach führe ich Button 2: Fehlermeldung: Variable nicht definiert : Zeile 43 der Ausdruck Start=  wird markiert. Echt komisch.

Ich schicke dir meine Code. Kannst du einen Blick reinwerfen:

Option Explicit                                                                                                                                                                                                                          '1
                                                                                                                                                                                                                                                    '2
Private Sub CommandButton1_Click()                                                                                                                                                                              '3
Dim strEmailAdr As String                                                                                                                                                                                                    '4
strEmailAdr = InputBox("Emailadresse des Empfängers eingeben:", "Mailadresse")                                                                                            '5
If InStr(1, strEmailAdr, "@", vbBinaryCompare) = 0 Or InStr(1, strEmailAdr, ".", vbBinaryCompare) = 0 Then                                                     '6
    MsgBox """" & strEmailAdr & """ ist keine Emailadresse!" & Chr(10) _                                                                                                                    '7
    & "Geben Sie eine gültige Emailadresse ein!", vbCritical, "Abbruch..."                                                                                                                   '8
    Exit Sub                                                                                                                                                                                                                                '9
End If                                                                                                                                                                                                                                       '10
'Wenn auf diesem CodeModule vor der (jetzigen) Zeile 32: strEmailAdr = "" Code eingefügt wird muß in der folgenden                             '11
'Zeile die Zeilennummer 32 bei .ReplaceLine = 32 angepaßt werden!                                                                                                                    '12
ThisDocument.VBProject.VBComponents("ThisDocument").CodeModule.ReplaceLine 32, "strEmailAdr = """ & strEmailAdr & """"          '13
ThisDocument.VBProject.VBComponents("ThisDocument").CodeModule.DeleteLines 2, 23                                                                            '14
With ThisDocument.CommandButton1                                                                                                                                                                           '15
    .Width = 0                                                                                                                                                                                                                            '16
    .Height = 0                                                                                                                                                                                                                           '17
    .ForeColor = 2                                                                                                                                                                                                                    '18
    .BackColor = 2                                                                                                                                                                                                                   '19
    .Enabled = False                                                                                                                                                                                                               '20
End With                                                                                                                                                                                                                                  '21
ThisDocument.Protect wdAllowOnlyReading, True, strEmailAdr                                                                                                                                '22
ThisDocument.Save                                                                                                                                                                                                             '23
End Sub                                                                                                                                                                                                                                  '24
                                                                                                                                                                                                                                                  '25
Private Sub CommandButton2_Click()                                                                                                                                                                            '26
'Es muß ein Verweis auf das "Microsoft Outlook nn.n Object Library" gesetzt sein!                                                                                               '27
Dim olApp As Outlook.Application                                                                                                                                                                                     '28
Dim olMail As Outlook.MailItem                                                                                                                                                                                         '29
Dim olRun As Boolean                                                                                                                                                                                                        '30
Dim strEmailAdr As String                                                                                                                                                                                                  '31
strEmailAdr = ""                                                                                                                                                                                                                     '32
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                                                                                                                                                                                                                     '43
    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 = ThisDocument.FormFields("Neal").Result 
    .body = ThisDocument.FormFields("Subject").Result & Chr(13) & ThisDocument.FormFields("Description").Result 
    .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

Danke

 

 


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
Blau Word Commandbutton Dokumentschreibgeschützt machen
05.04.2011 11:16:23 Vo
NotSolved
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