110,533
社区成员
发帖
与我相关
我的任务
分享
Type type;
object access = null;
object version = null;
type = Type.GetTypeFromProgID("Access.Application");//Access 判断出错 excel可以
if (type == null)
{
MessageBox.Show("没有安装access"); Application.Exit();
}
else
{
access = Activator.CreateInstance(type);
if (access == null)
{
MessageBox.Show("没有安装access");
Application.Exit();
}
else
{
version = type.GetProperty("Version").GetValue(access, null);
PropertyInfo p = type.GetProperty("Visible");
p.SetValue(access, true, null);//设置可见性
MethodInfo[] ms=type.GetMethods();//CloseCurrentDatabase 退出数据库
type.GetMethod("Quit").Invoke(access, null);//type.GetProperty("Visible").ReflectedType
}
}
if (version != null)
{
// MessageBox.Show("Excel版本号是:" + version.ToString());
}