2014-09-10 85 views
0

我正在寫一個函數,在調試窗口中輸出文件夾名稱。出於某種原因,當我調用這個函數時,我得到一個對象所需的錯誤。我已經設置了這個對象,所以我不確定哪裏出了什麼問題。任何幫助將不勝感激。謝謝!Outlook函數中的對象錯誤

function email_function(fldr as outlook.folder) 
     debug.print fldr 
    end function 



    Sub email() 

    Set objOutlook = CreateObject("Outlook.Application") 
    Set objNspace = objOutlook.GetNamespace("MAPI") 
    Set start_fldr = objNspace.GetDefaultFolder(olFolderInbox) 


    Debug.Print start_fldr 

    If Not start_fldr Is Nothing Then 
     email_function (start_fldr) 
    End If 

    End Sub 

回答

0

語法錯誤。

Call email_function(fldr) 

'or 

email_function fldr 

原始代碼問題:

Sub email() 
    Dim objOutlook As Application 
    Dim objnSpace As Namespace 
    Dim start_fldr As folder 
    Dim fldr As folder 

    Set objOutlook = Application 
    Set objnSpace = objOutlook.GetNamespace("MAPI") 
    Set start_fldr = objnSpace.GetDefaultFolder(olFolderInbox) 

    Set fldr = start_fldr.Folders.GetFirst 

    Call email_function(fldr) 

    email_function fldr 

End Sub 
+0

謝謝!有效。我知道這很簡單,我失蹤了。 – 2014-09-10 19:41:00

相關問題