2012年11月2日金曜日

MacOSX + Excel2011 + VBA + XCode4.5 + dylib

・MacOSX 10.7上で、Excel2011のVBAから、XCode4.5で作成したCのdylibファイルを呼び出す方法について。

・On MacOSX 10.7, how to call the function made by XCode4.5 in C language.


※以下のサイトを参考にしました。
※ I refered to the below URL.

http://social.msdn.microsoft.com/Forums/is/isvvba/thread/b060f291-0754-4e85-a7b9-e64259e6baad


1.XCodeを起動して、新規プロジェクトで、C/C++ Libraryを選択。
・Open XCode , and create " C/C++ Library" Project.


2.TypeをDynamicにして、「Next」
・Select "Dynamic" Type.




3.Excel2011は、32bitモードで動いているので、dylibファイルも32bitでビルドします。
「Setting」の「Architecture」を「32-bit intel」に変更します。

Excel2011 is running in 32-bit,so we should build dylib on 32bit.
Select "32-bit intel" on  "Architecture" .



4.C、もしくは、C++ファイルを作成して、メソッドを作り、「Run」を押して、
dylibファイルをビルドします。

 Create C/C++ File ,and make function code.And push "Run" Button.
  






5.ビルドがおわったら、ビルドされたファイルの場所を確認します。
必要があれば、Excelファイルと同じ場所等へ、dylibファイルを移動させます。

 After built,check the dylib file path.If you need, move dylib file to the dirctory where Excel file exists.





6.ExcelのVBAを起動して、コードを書きます。
Open Excel VBA Editor , coding.




7.VBAのコードを実行します。
Run VBA Code.











0 件のコメント: