Pages

19/10/2018

VBA export outlook address book as csv



話說很久很久以前,杜芬宅學了VB。
VB 到了今天都差不多名存實忙,沒人會用,一般的程式用C#就好。
十年前苦練的VB,今天終於大派用場


前言


Visual Basic 同是 Microsoft 開發的語言,相比 C#,VB的入門門檻低,VB 6.0 Control Creation Edition 是免費版本,相信是當年學校會教的原因。
當年很狂熱的玩了一段時間,在PowerPoint 寫通關密語,只要回答正確就給你一些資訊。

不過杜芬宅認為VB是一個過渡性的產品,現在應該要被取締。
因為VB的語法很怪胎,不適合假如想在 Programming 中長遠發展時需要打下的根基,會學壞手勢。

萬萬想不到,若干年後的今日,杜芬宅會用到。

背景

今次的scope 很簡單,就是有人想在Outlook拿走全部聯絡人的資料


程式碼

188 行的程式碼,給你

不明白為什麼操控 Office 365 的產品還是要用VBA,用C#不就好,但也不深究了。


感想

杜芬宅最討厭讀M$的說明文件,所有中文字我也懂,但是加在一起,看完都不知道它說什麼。
最愛的是Google 的說明文件,給人的感覺很一致,有一個整體很整齊、漂亮的感覺。
M$的文件,說同一樣事物,可以有幾個連結,幾個文件各自展述,令人相信是不同團隊製作,使用體驗很差。
而且杜芬宅很討厭M$的介面,很醜,沒有HCI優化。

結論是,如果上司叫你寫VBA,只好自求多福啦。
總之杜芬宅很討厭VB,討厭VBA,討厭上班。

Reference

杜芬宅爬了十篇文章才寫完那個,好累呀,請給杜芬宅飼料。

about syntax

Shorthand for x=x+1?
https://stackoverflow.com/questions/20075651/shorthand-for-x-x1

Excel Macro : How can I get the timestamp in “yyyy-MM-dd hh:mm:ss” format?
https://stackoverflow.com/questions/5457069/excel-macro-how-can-i-get-the-timestamp-in-yyyy-mm-dd-hhmmss-format

How can I concatenate strings in VBA?
https://stackoverflow.com/questions/1727699/how-can-i-concatenate-strings-in-vba

VBA + Excel + Try Catch
https://stackoverflow.com/questions/44638867/vba-excel-try-catch

How to create a separate CSV file from VBA?
https://stackoverflow.com/questions/8419828/how-to-create-a-separate-csv-file-from-vba

Appending a dynamic array in VBA
https://stackoverflow.com/questions/28684942/appending-a-dynamic-array-in-vba

Adding an element to the end of an array
https://superuser.com/questions/808798/adding-an-element-to-the-end-of-an-array

How do I put double quotes in a string in vba?
https://stackoverflow.com/questions/9024724/how-do-i-put-double-quotes-in-a-string-in-vba

How can I use a for each loop on an array?
https://stackoverflow.com/questions/4228137/how-can-i-use-a-for-each-loop-on-an-array

Get length of array?
https://stackoverflow.com/questions/30574814/get-length-of-array

return array from function in VBA
https://stackoverflow.com/questions/31564846/return-array-from-function-in-vba/31565124

Excel VBA: Failed to pass a string array to a Function
https://stackoverflow.com/questions/31672463/excel-vba-failed-to-pass-a-string-array-to-a-function

What's wrong with this snippet of VBA code?
https://stackoverflow.com/questions/10159126/whats-wrong-with-this-snippet-of-vba-code

Get FirstName based on Alias Outlook search in vba
https://stackoverflow.com/questions/32943435/get-firstname-based-on-alias-outlook-search-in-vba/32943940


about strange

Continue For loop
https://stackoverflow.com/questions/5895908/continue-for-loop

Break out of a While…Wend loop
https://stackoverflow.com/questions/12200834/break-out-of-a-while-wend-loop

How do you redimension an array in VBA?
https://stackoverflow.com/questions/890709/how-do-you-redimension-an-array-in-vba


similar example

How to pull from Outlook Address book based on values in Excel (VBA)
https://stackoverflow.com/questions/23666303/how-to-pull-from-outlook-address-book-based-on-values-in-excel-vba

Introduction - Export Outlook Contacts to Excel
https://wellsr.com/vba/2016/outlook/export-outlook-address-book-to-excel/

Outlook & VBA : Export contact information to Excel
https://blogs.msdn.microsoft.com/deva/2008/09/17/outlook-vba-export-contact-information-to-excel/

How to retrieve GAL info into Outlook contacts with VBA?
https://forums.windowssecrets.com/showthread.php/121886-How-to-retrieve-GAL-info-into-Outlook-contacts-with-VBA

Export contacts from Outlook to Excel - automate in vba
http://www.globaliconnect.com/excel/index.php?option=com_content&view=article&id=166:export-contacts-from-outlook-to-excel-automate-in-vba&catid=79&Itemid=475


Outlook API

AddressEntry.GetExchangeUser Method
https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb175075(v=office.12)

ExchangeUser Object (Outlook)
https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/ff866281%28v%3doffice.14%29#version-information

Outlook Object Model Reference
http://msdn.microsoft.com/en-us/library/office/ff870566(v=office.14).aspx

AddressEntry Object
http://msdn.microsoft.com/en-us/library/office/ff870588(v=office.14).aspx

No comments:

Post a Comment