使用VB区分C#Interop或Excel程序中的xlsx事件 [英] Use VB to distinguish between an xlsx event from C# Interop or Excel program

查看:86
本文介绍了使用VB区分C#Interop或Excel程序中的xlsx事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我要在用户关闭.xlsx文件时触发的事件.我也有一个C#程序,可以定期检查同一文件中的内容.我的问题是,当我的C#程序(使用Interop)关闭.xlsx文件时,它会触发我的VB代码.有没有办法隔离对excel文件的访问,以便我知道它是在Excel程序中编辑的?

I have an event that I want triggered when a user closes a .xlsx file. I also have a C# program that regularly checks the content within that same file. The problem I have is that when my C# program (which uses Interop) closes the .xlsx file, it triggers my VB code. Is there a way to isolate access to the excel file so that I know it was edited within the Excel program?

我只希望在用户在Excel中编辑文件时触发我的VB代码.

I only want my VB code triggered when a user edits the file within Excel.

谢谢

推荐答案

我决定只让C#程序在开头创建一个临时文件,然后在结尾将其删除.如果VB看到了临时文件,则意味着C#必须正在编辑excel文件,否则我们可以假定它是用户.

I decided to simply have my C# program create a temp file at the beginning and delete it at the end. If VB sees the temp file, it means that C# must be editing the excel file, otherwise we can assume it is a user.

这篇关于使用VB区分C#Interop或Excel程序中的xlsx事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆