WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Excel ObjectGet and UAC

 Keywords: Excel ObjectGet Win7 Windows 7 UAC 

Question:

WB2011A
Win7 Home Premium SP1
Office 2003
I'm having difficulty getting WB to access an existing instance of Excel.

Although two workbooks are open, the below code opens a new instance of Excel and terminates with the message that there is no active workbook.

oXL = ObjectGet(, "Excel.Application")
oXL.visible = @TRUE
oActiveWorkbook = oXL.ActiveWorkbook
Terminate(oActiveWorkbook==0,`Excel Status`,`No Active Workbook`)
Message(`Active Workbook`,oActiveWorkbook.Name)

Answer:

Simply because ~95% of all Windows 7 issues seem to be UAC related, I am guessing that the likely cause is that you are running the WinBatch Script with elevated privileges and Excel with reduced privileges.

I could easily be wrong but given the facts that the debug trace indicates that the script is elevated, that Excel does not by default launch elevated, that an elevated processes cannot access a reduced privileges process's ROT entries, I am putting my wooden nickel on a UAC problem.

If uac elevation is the cause then maybe modifying the manifest settings used could have an effect. The easiest way to confirm that UAC is the cause is to change the extension of the script attempting to attach to Excel from 'wbt' to 'wbt_if' and launch it from a shell Explorer windows. If it works with an existing Excel instance, cause confirmed.

User Reply:

Yes, that was the solution - renaming .wbt to .wbt_if. It was in fact a UAC problem.
Article ID:   W18107
Filename:   Excel ObjectGet and UAC.txt
File Created: 2012:05:31:08:24:34
Last Updated: 2012:05:31:08:24:34