what is the role of VBE7.dll? - excel

The application is writing data to the excel sheet.
As per our security standards we are blocking macros related to excel and word.
McAfee antivirus is blocking the macros.
The application is in C++ and the data written to excel is done by using MFC and worksheet functions.
when i debugging the code, it is trying to write or execute VBE7.dll and VBE7.dll is blocking by McAfee.
why it is trying to write or execute to VBE7.dll?

Related

Error in one vba workbook causes other independent workbooks to stop running

I've written a number of programs that monitor devices and records data. The programs are continuously running. I'm usually monitoring several devices using separate workbooks that are independent from each other. However, if one program gets an error, all of VBA stops, including those other programs.
Is there a way to have separate instances of VBA? So if one faults the others can still run? Thanks.
If you want an error in one workbook not to affect running code in another, you can use separate instances of Excel to run each macro.
To start a new instance, hold down the Alt key while opening Excel - it will ask you if you mean to start a new instance. Or you can create a new instance from VBA using CreateObject()

Cannot get external data during DoEvents

I have a VBA sub in Excel that executes DoEvents until the requirements are met. During this loop, I need to get external data & import that data as a table into the active worksheet. I cannot click "Existing connections" when the VBA code is in this section, and I don't understand why I can't do this. Can anyone explain to me why this isn't possible?
DoEvents allows other applications time to run and prevents your VBA code from locking the entire system. It does not allow you to interact with the VBA host application (Excel in this case), because the VBA code is currently executing.
From the MS documentation:
The DoEvents function surrenders execution of the macro so that the operating system can process other events. The DoEvents function passes control from the application to the operating system. Some instances in which DoEvents may be useful include the following:
Hardware I/O
Delay Loops
Operating System Calls
DDE Deadlocking
Emphasis mine
You may want to investigate integrating the 'get external data & import' process into your VBA code. It would, however, have to happen either before or after the DoEvents loop, not during.

Embedded Excel COM Object clipboard interefernce

I'm writing programs in C\C++ embedding Excel and handling it's COM object.
This automation process works flawlessly to manipulate sheets and getting benefit of excel capabilities.
M problem is that while processing data i use copy/paste operations, so if the processing takes some time, it's possible that interference happens as the clipboard is common between running processes
i don't know if there's a way privatize the clipboard or any other idea to avoid such problem
Thanks in advance
You cannot make a private clipboard and expect it to work with normal cut/copy/paste operations. You can use delays to avoid clipboard clashes. i.e. after you force a copy operation, wait a few hundred ms before pasting.
Also, programmatic use of the clipboard is considered bad practice. The clipboard is provided for the convenience of the user, not the programmer. See my favorite quote on the subject:
“Programs should not transfer data into our out of the clipboard
without an explicit instruction from the user.” — Charles Petzold,
Programming Windows 3.1, Microsoft Press, 1992
I found a way to do it for PowerShell scripts:
Create a Scheduled Task that call your script/program
Set it to "Run whether user is logged on or not"
When you run the Scheduled Task, Windows launch the script/program in a background session that uses its own Clipboard, not interfering with the one of the active session you have.

Is Scheduled, Unattended Server-Based Creation of Excel Workbook With VBA Possible?

I'd like to be able to schedule an Excel macro (VBA) to run in the middle of the night (after a file is ready) to create a customized workbook (multiple sheets, pivot tables, charts, filters, outlines, custom formatting, etc.). Currently, the macro is fired up manually the next day. Furthermore, it needs to run unattended on a server (laptop goes home at night!). Anybody successfully do something like this? Please, no Unix-side hacks (e.g., Perl modules) - need full access to VBA features, including database functions. Thanks!
Well you have some options.
First, for all Excel has to be installed on server.
Then you create a sheduled task to call a program.
In this case you can write e.g. a vbscript or .NET program to call the app, load the document and starts its content (your VBA). That should work at all.
Or you move the VBA code to a program and target Excel with your code, but prolly more work.
If you do this with .NET you have prolly best success. e.g. you can add an eventlog for successful run, etc.
If you can leave Excel running on the server all the time, you can use Application.OnTime to schedule the next runs of a particular macro (once it's run, reschedule another in the macro code). When I worked in banking we used this all the time to run night-time jobs.
If you cannot leave Excel running, I have to say you may be in a world of pain. It's possible to start Excel using an AT job (scheduled task) but you may have headaches getting it to run under the correct user privileges and if you use any addins you'll experience regular disasters where they failed to load and stopped Excel from starting up. At the end of the day, Excel isn't really meant to be run on servers (it's actually a violation of the terms of use) and starting/running/stopping it is not going to be a reliable system even if you do get it to work.

Excel Process Hangs when Run by MSTest from CruiseControl.NET

I'm using CruiseControl.NET with MSTest to build my Excel add-in. Some of my tests involve opening Excel, performing some operations and checking the results. This is all achieved through COM.
If I run the tests from with Visual Studio 2008, they work perfectly. However, when the tests are started by CruiseControl, the Excel process is created but just hangs. The test process will only continue if I kill the Excel process. The webdashboard then reports an error in the TestInitialize function: which basically just creates and instance of Excel and loads my XLL.
Does anybody have any idea what might be the solution to my problem? I'm using Excel 2007 on my build server.
Thanks,
Chris
This is usually because there are undisposed objects that are still lingering around. You either need to be somewhat more robust in your test clearup (think workbooks, worksheets, worksheet, range - and possibly more) or you could go for a brute force approach and kill any excel instance using the Process class as part of your TestSetUp() method.

Resources