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

MSAccessのaccdb/accde/mdbファイルみたいなのを自動でPC起動時に起動したいときのアレ

Posted at

はじめに

社内ではMSAccessをアプリ基盤としてごりごり使っているのですが、
PC起動時に勝手にアプリが上がってくるようにしてほしい(という方向性のアプリを作ってほしい)なんて話が上がってきました。

だが、調べてみると、意外にまとまった情報が無い。

ということで

つくってみました。以下のソースを適当な標準モジュールにインポートして使うと幸せになれるかもしれないです。

とりあえず動作確認してるのは

・Windows10 Pro 1903
・Microsoft Access 2013と2012

です。
(バージョン依存してる書き方などしていないと思うので、ほとんどのバージョンで動くだろうとは思いますが)

おソース

Option Compare Database
Option Explicit

Const SHORTCUTNAME = "\hogehoge.lnk"    '拡張子はlnkないしurlで終わらないとダメらしい

Public Sub CreateShortCut_ToStartup()
    Dim ws As Object
    Dim myShortcut As Object
    
    Set ws = CreateObject("WScript.Shell")
    Set myShortcut = ws.CreateShortCut(ws.SpecialFolders("startup") & SHORTCUTNAME)
    
    With myShortcut
        .TargetPath = CurrentProject.FullName
        .Save
    End With
End Sub

Public Sub DeleteShortCut_ToStartup()
    Dim ws As Object
    
    Set ws = CreateObject("WScript.Shell")
    If 0 < Len(Dir(ws.SpecialFolders("startup") & SHORTCUTNAME)) Then
        Kill ws.CreateShortCut(ws.SpecialFolders("startup") & SHORTCUTNAME)
    End If
End Sub

なにかあればコメなりプルリクで。

2
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
2
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?