WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Problem mit Outlook Skript (OL2003) (http://www.wcm.at/forum/showthread.php?t=194097)

Martin 1 24.06.2006 20:41

Problem mit Outlook Skript (OL2003)
 
Hallo!

Habe mir aus dem Internet ein kleines Skript zusammengestöpselt, mit dem ich eine bestehende PST Datei öffnen und wieder schließen möchte.

Zum Öffnen:

Sub Datensyncro_Martin_oeffnen()

Dim sFileName$

sFileName = ("J:\Outlook Martin\Datensyncro_Martin.pst")
OpenFolder sFileName

End Sub

Sub OpenFolder(strFileName As String)
Dim oOutlook As Outlook.Application
Dim oNSpace As Outlook.NameSpace

Set oOutlook = CreateObject("Outlook.Application")
Set oNSpace = oOutlook.GetNamespace("MAPI")
oNSpace.AddStore strFileName

Set oOutlook = Nothing
Set oNSpace = Nothing

End Sub

Zum Schließen:

Sub Datensyncro_Martin_schliessen()

Dim objOL As New Outlook.Application
Dim objName As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Set objName = objOL.GetNamespace("MAPI")
Set objFolder = objName.Folders.Item("Mailsynchronisierung")
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to remove the Personal Folders file?"
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objName.RemoveStore objFolder
End If
End Sub


Nun habe ich das Problem,dass das Skript beim Öffnen leider nicht überprüft ob die Datei überhaupt vorhanden ist und trotzdem die PST Datei öffnet, obwohl diese gar nicht vorhanden ist (befindet sich auf USB-Stick).

Nun kann ich die so "geöffnete" PST Datei nicht mehr aus Outlook entfernen. Bekomme die Meldung "Der Vorgang konnte nicht ausgeführt werden. Ein Objekt wurde nicht gefunden".

Was stimmt nun an dem Skript nicht, bzw. wie kann ich eine Warnfunktion einbauen, die bei nicht vorhandener Zieldatei warnt.

Und zuletzt wie bekomme ich diesen Ordner nun wieder aus Outlook heraus?

Schöne Grüße
Martin

wbendl 25.06.2006 09:18

Hi!

http://vb-tec.de/fdexists.htm#code


mfg

WB


Alle Zeitangaben in WEZ +2. Es ist jetzt 16:53 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag