0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQLserverを立ててエクセルVBAでデータを取得できるにした時の備忘録

Last updated at Posted at 2019-10-13

マスタDBの作成

SQLserverでDBを立てました。
https://qiita.com/mrsr6113/items/477599bb6e4ce522bf88

エクセルでSQLserverからデータを取得する

こちらで公開されているコードを使用させていただきました。
https://hosopro.blogspot.com/2017/07/excelsql-server.html

「ユーザー定義型は定義されていません。」エラーで焦る

こちらを参照させていただきました。
https://tsware.jp/tips/tips_334.htm

「ActiveX Data Objects 2.Xのチェックを外す」となっていましたが、エラーが出ましたので下記にチェックを入れたところ解消しました。
Microsoft DAO 3.X Object Library
また、今回はMicrosoft ActiveX Data Objects 6.X Libraryを使用しました。

作成したエクセルでVBAが保存できない

久しぶり過ぎてうっかりしてましたが、保存形式が「.xlsm」にしないとダメですね。

SQLserverからselectするだけなら「データの取得」が便利

わざわざVBAを使わなくてもデータを取得するだけならGUIでできるようになってますね。。
「データ」タブ - 「データの取得」 - 「データベースから」
本当に便利になったものです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?