Am Sun, 16 Oct 2005 16:48:54 -0400 schrieb John Strung:
Ok, it seems to be a bug in the CommandBars. For me it also toggles between
two different signatures.
I tested with these few lines:
Set ObjCB = olApp.ActiveInspector.CommandBars("Menu Bar")
Set ObjPop = ObjCB.FindControl(, 30005)
Set ObjPop = ObjPop.CommandBar.FindControl(, 31145)
TEST_AGAIN:
Set ObjCtl = ObjPop.Controls.Item(2)
Debug.Print ObjCtl.Caption
ObjCtl.Execute
Set ObjCtl = Nothing
If MsgBox("test again", vbYesNo) = vbYes Then GoTo TEST_AGAIN
So, please, go the way to read the files yourself. The following sample is
from Thorsten Dörfler, a German VB MVP.
This call returns the directory for the sig files:
dim s$
s=GetSpecialFolder(ssfAPPDATA)
if right(s,1)<>"\" then s=s & "\"
s=s & "Microsoft\Signatures\"
<modSpecialFolder>
'----------------------------------------------------------------------------
' Module :modSpecialFolder2
' DateTime :12.01.2004 08:43
' Author :Thorsten Dörfler
' Bei Verteilung muss darauf geachtet werden, die shfolder.dll mitzugeben.
' Die DLL darf aber nicht registriert werden, weil es keine Com-DLL ist.
'----------------------------------------------------------------------------
Option Explicit
Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Declare Function SHGetFolderPath Lib "shfolder" Alias
"SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByRef ppidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" _
(ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long
Private Const S_OK = 0
Private Const MAX_PATH = 260
Private Const CSIDL_FLAG_CREATE = &H8000&
Public Enum ShellSpecialFolderConstants
ssfDESKTOP = &H0
ssfPROGRAMS = &H2
ssfPERSONAL = &H5
ssfFAVORITES = &H6
ssfSTARTUP = &H7
ssfRECENT = &H8
ssfSENDTO = &H9
ssfSTARTMENU = &HB
ssfMYMUSIC = &HD
ssfDESKTOPDIRECTORY = &H10
ssfNETHOOD = &H13
ssfFONTS = &H14
ssfTEMPLATES = &H15
ssfCOMMONSTARTMENU = &H16
ssfCOMMONPROGRAMS = &H17
ssfCOMMONSTARTUP = &H18
ssfCOMMONDESKTOPDIRECTORY = &H19
ssfAPPDATA = &H1A
ssfPRINTHOOD = &H1B
ssfLOCALAPPDATA = &H1C
ssfALTSTARTUP = &H1D
ssfCOMMONALTSTARTUP = &H1E
ssfCOMMONFAVORITES = &H1F
ssfINTERNET_CACHE = &H20
ssfCOOKIES = &H21
ssfHISTORY = &H22
ssfCOMMONAPPDATA = &H23
ssfWINDOWS = &H24
ssfSYSTEM = &H25
ssfPROGRAMFILES = &H26
ssfMYPICTURES = &H27
ssfPROFILE = &H28
ssfPROGRAMFILESCOMMON = &H2B
ssfCOMMONTEMPLATES = &H2D
ssfCOMMONDOCUMENTS = &H2E
ssfCOMMONADMINTOOLS = &H2F
ssfADMINTOOLS = &H30
ssfCOMMONMUSIC = &H35
ssfCOMMONPICTURES = &H36
ssfCOMMONVIDEO = &H37
ssfRESOURCES = &H38
ssfRESOURCESLOCALIZED = &H39
ssfCDBURNAREA = &H3B
End Enum
Public Function GetSpecialFolder(ByVal Folder As
ShellSpecialFolderConstants, _
Optional ByVal ForceCreate As Boolean) As String
Dim tIIDL As ITEMIDLIST
Dim strPath As String
Dim hMod As Long
If (ForceCreate) Then
Folder = Folder Or CSIDL_FLAG_CREATE
End If
If SHGetSpecialFolderLocation(0, Folder, tIIDL) = S_OK Then
strPath = Space$(MAX_PATH)
If SHGetPathFromIDList(tIIDL.mkid.cb, strPath) <> 0 Then
GetSpecialFolder = left$(strPath, InStr(1, strPath, vbNullChar) - 1)
End If
Else
strPath = Space$(MAX_PATH)
hMod = LoadLibrary("shfolder")
If (hMod <> 0) Then
If SHGetFolderPath(0, Folder, 0, 0, strPath) = S_OK Then
GetSpecialFolder = left$(strPath, InStr(1, strPath, vbNullChar) - 1)
End If
FreeLibrary hMod
End If
End If
End Function
</modSpecialFolder>
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
> Private Sub email_button_Click()
> Dim varx As String, lawinits As String
> Dim usnm As String, criteria As String, MyDB As Database
> Dim MySet As DAO.Recordset, emaccess As String, nomatch As Variant
> Dim x As Long
> On Error GoTo emailerrorhandler
>
> Dim olApp As Object
> Dim objNewMail As Object
> Dim objONewmail As Object
> Dim AddressString As String, SubjectString As String
> Dim bodystring1 As String, bodystring2 As String, bodystring3 As String
> Set olApp = New Outlook.Application
> Set objONewmail = olApp.CreateItem(olMailItem)
> Set objNewMail = CreateObject("REDEMPTION.SafeMailItem") 'Circumvents
> Outlook Security Patch
> objNewMail.Item = objONewmail
> With objNewMail
> AddressString = CStr(Me![email])
> SubjectString = CStr([File Name])
> bodystring1 = "Our File Number: " & CStr([File Number]) & Chr(10)
> bodystring2 = ""
> bodystring3 = ""
> If IsNull(Me![Claimno]) = 0 Then bodystring2 = "Your Claim Number: " &
> CStr(Me![Claimno]) & Chr(10)
> If IsNull(Me![DateLoss]) = 0 Then bodystring3 = "Date of Loss: " &
> CStr(Me![DateLoss]) & Chr(10)
>
> bodystring1 = bodystring1 & bodystring2 & bodystring3 &
> "-------------------------" & Chr(10) & Chr(10) & Chr(10)
> .Recipients.Add AddressString
> .Recipients.ResolveAll 'TEST THIS LINE
> .Subject = SubjectString
> .Body = bodystring1
> .Display
>
>
> 'The next section inserts the default signature file
>
> 'Dim objOutlook As Outlook.Application
> Dim ObjCtl As Office.CommandBarControl
> Dim ObjPop As Office.commandBarPopup
> Dim ObjCB As Office.CommandBar
> Dim ObjItem As Object
>
> 'Set objOutlook = CreateObject("Outlook.Application")
> 'Set ObjCB = objOutlook.ActiveInspector.CommandBars("Menu Bar")")
> Set ObjCB = olApp.ActiveInspector.CommandBars("Menu Bar")
> Set ObjPop = ObjCB.Controls("Insert")
> Set ObjPop = ObjPop.Controls("Signature")
> Set ObjCtl = ObjPop.Controls.Item("letterhead")
> ObjCtl.Execute
> 'Set objOutlook = Nothing
> Set ObjCtl = Nothing
> Set ObjPop = Nothing
> Set ObjCB = Nothing
> Set ObjItem = Nothing
>
> 'Next section moves Cursor to bottom of message before inserting signature
>
> 'SendKeys "{tab}", True
> 'SendKeys "{pgdn}", True
> 'SendKeys "{pgdn}", True
>
> 'set cursor position with the Inspector instead
> x = 6
> Dim sInspector
> Dim plaintexteditor
> Set sInspector = CreateObject("Redemption.SafeInspector")
> sInspector.Item = Outlook.ActiveInspector
> Set plaintexteditor = sInspector.plaintexteditor
> plaintexteditor.CaretPosY = x
>
> Dim objOutlook2 As Outlook.Application
> Dim ObjCtl2 As Office.CommandBarControl
> Dim ObjPop2 As Office.commandBarPopup
> Dim ObjCB2 As Office.CommandBar
> Dim ObjItem2 As Object
>
> 'Set objOutlook2 = CreateObject("Outlook.Application")
> 'Set ObjCB2 = objOutlook2.ActiveInspector.CommandBars("Menu Bar")
> Set ObjCB2 = olApp.ActiveInspector.CommandBars("Menu Bar")
> Set ObjPop2 = ObjCB2.Controls("Insert")
> Set ObjPop2 = ObjPop2.Controls("Signature")
> Set ObjCtl2 = ObjPop2.Controls.Item("Full Signature")
>
> ObjCtl2.Execute
>
> 'Set objOutlook2 = Nothing
> Set ObjCtl2 = Nothing
> Set ObjPop2 = Nothing
> Set ObjCB2 = Nothing
> Set ObjItem2 = Nothing
>
>
>
> 'set cursor position with the Inspector
> x = 6
> If IsNull(Me![Claimno]) = True Then x = x - 1
> If IsNull(Me![DateLoss]) = True Then x = x - 1
> 'Dim sInspector
> 'Dim plaintexteditor
> Set sInspector = CreateObject("Redemption.SafeInspector")
> sInspector.Item = Outlook.ActiveInspector
> Set plaintexteditor = sInspector.plaintexteditor
> plaintexteditor.CaretPosY = x
>
> End With
>
> Set olApp = Nothing
>
> Dim utils
> Set utils = CreateObject("Redemption.MAPIUtils")
>
>
> Exit Sub
>
>
> Exit Sub
>
> emailerrorhandler:
> On Error GoTo 0
> MsgBox "Open the In Box in MS Outlook and try again"
> Exit Sub
> End Sub