我得到了一個VB SCRIPT在互聯網上創建Outlook(2010)中的輔助電子郵件帳戶的新郵件提醒。Visual Basic編譯錯誤 - 無效字符
現在,這是代碼的第一部分,並運行Outlook時,它給了我下面的錯誤:
「編譯錯誤:無效字符」
調試器強調了_字符的下面一行:「sndPlaySoundA」 _
'On the next line change the file name and path of the sound you want to play.'
Public Const SOUND_TO_PLAY = "C:\Windows\Media\Speech On.wav"
Public Const SND_ASYNC = &H1
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Public Declare Function MessageBox _
Lib "User32" Alias "MessageBoxA" _
(ByVal hWnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal wType As Long) _
As Long
Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder
' Purpose: Opens an Outlook folder from a folder path.'
' Written: 4/24/2009'
' Author: BlueDevilFan'
' Outlook: All versions'
Dim arrFolders As Variant, _
varFolder As Variant, _
bolBeyondRoot As Boolean
On Error Resume Next
If strFolderPath = "" Then
Set OpenOutlookFolder = Nothing
Else
Do While Left(strFolderPath, 1) = "\"
strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
Loop
arrFolders = Split(strFolderPath, "\")
For Each varFolder In arrFolders
Select Case bolBeyondRoot
Case False
Set OpenOutlookFolder = Outlook.Session.Folders(varFolder)
bolBeyondRoot = True
Case True
Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder)
End Select
If Err.Number <> 0 Then
Set OpenOutlookFolder = Nothing
Exit For
End If
Next
End If
On Error GoTo 0
End Function
更新:一個新的錯誤已經上升:(之後我「sndPl後固定在1號線新線問題aySoundA「)由以下阿德里安)refered到
」編譯錯誤預期:語句結束「 和下列字突出顯示: 」公「
UPDATE2:下一個錯誤:
編譯錯誤:用戶定義類型沒有定義(對於「郵箱 - supportdesk \收件箱」)
Dim objFM1 As FolderMonitor
Private Sub Application_Quit()
Set objFM1 = Nothing
End Sub
Private Sub Application_Startup()
Set objFM1 = New FolderMonitor
'Edit the folder path on the next line as needed.'
objFM1.FolderToWatch OpenOutlookFolder("Mailbox - supportdesk\Inbox")
End Sub
我不熟悉FolderMonitor。它是內置的Outlook類還是單獨的庫?如果它是分開的,您是否在工具>參考下添加了對它的引用? – Adrian
不,我認爲我沒有...會看到我能做什麼 – DextrousDave