英文:
How can I acces my Programms on my OfficeLine which is running on Access with C# code?
问题
I understand your request, and here's the translated text without the code:
基本上,我正在使用一个运行在Access上的OfficeLine,我的程序列表如下:
现在,我想从C#中打开其中一个。
我尝试使用Interop.Access来实现这一点,因为我的C#程序是一个类库程序。
然后,我尝试从Access中获取所有的表单,因为在我的任务管理器中,我的OfficeLine看起来像这样:
我使用以下代码来获取表单:
foreach (Form form in accessApp.Forms)
{
try
{
// 检查表单是否已打开
if (!accessApp.Forms[form.Name].CurrentView.Equals(AcFormView.acDesign))
{
if (form.Name == "frmSysControlCenter")
{
foreach (Microsoft.Office.Interop.Access.Control control in form.Controls)
{
// 在此处理控件
}
}
}
else
{
// 表单处于设计模式
}
}
catch
{
// 如果出现错误,表单未打开
}
}
frmSysControlCenter 应该是表单,但现在我不知道如何从我的OfficeLine中访问表单,我尝试查看控件,但没有成功。
有没有人有想法如何从我的第一个截图中打开一个表单,比如 Stammdaten -> Artikel?
英文:
So bassicly im using an OfficeLine which is running on Access and my programms are list like that:
and now I want one of them open from C#.
I tried to use Interop.Access for that because my C# programm is an Class Library program.
And then to get all Forms from Access because in my Task manager my Officline is looking like that:
and I get the Form with that Code:
foreach (Form form in accessApp.Forms)
{
try
{
// Überprüfen, ob Formular geöffnet ist
if (!accessApp.Forms[form.Name].CurrentView.Equals(AcFormView.acDesign))
{
//MessageBox.Show("Das ist der if Block: " + form.Name);
if (form.Name == "frmSysControlCenter")
{
foreach (Microsoft.Office.Interop.Access.Control control in form.Controls)
{
}
}
}
else
{
MessageBox.Show("Das ist der else Block: " + form.Name);
}
}
catch
{
// Falls ein Fehler auftritt, das Formular ist nicht geöffnet
}
}
and frmSysControlCenter should be the Form but now I dont know how to access the formulars from my OfficeLine I thought on something like looking through Controls but that didnt work.
So anyone an Idea how to open an Formular like Stammdaten -> Artikel for example from my first screenshot?
答案1
得分: 0
我自己找到了一种方法,只需使用以下代码:
dynamic app = Marshal.GetActiveObject("Access.Application");
英文:
I found an way by myself and it was just to use this:
dynamic app = Marshal.GetActiveObject("Access.Application");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论