0
1

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 3 years have passed since last update.

Accessランタイム2019でaccdb へアクセス(C#)

Posted at

Accessランタイムの場合、Access.Application = new Access.Applicationで落ちるのでその対策

    private void button1_Click(object sender, EventArgs e)
    {
        Application ac = null;
        IWshShell3 ws = (WshShell)Interaction.CreateObject("WScript.Shell", "");
        ws.Run(@"C:\work\test.accdb");
        ac = (Application)Marshal.GetActiveObject("Access.Application");
        //アクセスの処理

        ac.Quit();
    }

accdbかmdbを開いておく必要があるので、ダミーファイルが必要になってしまうのと、
Run実行後にAccessのダイアログが入るのがいまいち。
image.png
image.png

開くを押下後でないとGetActiveObjectで例外エラーになるのでダイアログをどうにかする必要がある。
レジストリ書き換えるか何かほかに方法があるか...

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?