Questions tagged [excel.application]

Use to focus your question on the use of an Excel.Application object outside of Excel's own VBA. Constructing an independent instance of Excel can present unique problems and this tag can be used to identify them. Examples: PowerShell or VB Script referencing and manipulating an Excel workbook; MS Access building a workbook without leaving its own VBA environment, etc. Should be considered a sub-category and used for focusing a question.

Excel is arguably the most popular of the applications within the MS Office suite; even more so when introductory programming is considered a factor. Excel workbooks and worksheets can be easiy manipulated outside of the native Excel environment by introducing an instance of an Excel.Application object and using that object to programmatically handle data retrieval, creation or modification.

This presents unique problems, particularly in addressing parent/child relationships that are taken for granted in a native Excel environment. Use this tag to focus attention on these issues when you are using an independent instance of the Excel.Application from an outside calling process.

Typical examples of outside calling processes would include , or even each of which can construct an instance of an object and use it to wrangle the data stored in a workbook/worksheet.

References:

36 questions
7
votes
2 answers

"New" Excel.Application vs Excel.Application

I am seeking clarification on the impact of "New" on the objects and the script. My understanding is that if I need to perform actions on an excel document and the application is closed then I should use New Excel.Application. If I keep this…
ProtoVB
  • 773
  • 5
  • 12
  • 24
4
votes
1 answer

Python win32com.client and "with" statement

Good afternoon, I am writing some ETL scripts with Python, and am currently using win32com.client to open and refresh some data connections in Excel. My question is this: should I be using a with statement to open/close "Excel.Application" as…
smugs
  • 43
  • 7
4
votes
1 answer

How to properly close Excel.Application?

I have a small script that allows me to merge multiple .csv to a .xlsx: $path = "C:\Users\FrancescoM\Desktop\CSV\Results\*" $csvs = Get-ChildItem $path -Include *.csv $y = $csvs.Count Write-Host "Detected the following CSV files: ($y)" Write-Host "…
Francesco Mantovani
  • 10,216
  • 13
  • 73
  • 113
2
votes
1 answer

Rounding number from XML to Excel

I'm reading some value from XML: 20151027301060001 $DSN = $xml.metaBI.DocumentSetNumber and then writing to Excel using PowerShell: $ExcelWorkSheet.Cells.Item($Row,1).Value2 = $DSN But in Excel I'm getting…
Alexan
  • 8,165
  • 14
  • 74
  • 101
2
votes
1 answer

Powershell find excel cell reference

I am using the following powershell code to search through a excel document for a string and return true or false depending on if its found. if (test-path $filePath) { $wb = $xl.Workbooks.Open($filePath) if ([bool]$xl.cells.find("German")) {$found =…
Silentbob
  • 2,805
  • 7
  • 38
  • 70
2
votes
1 answer

Test if Excel has finished its startup / shutdown sequence

I'm using PowerShell to automate some excel tasks via COM, via a PowerShell script like so: $xl = new-object -ComObject Excel.Application sleep 5 DO THINGS... $xl.quit() sleep 5 $null =…
Jthorpe
  • 9,756
  • 2
  • 49
  • 64
2
votes
1 answer

vbscript to open an excel file in Windows 10 via Task Scheduler

I have a script file that I'm executing via Task Scheduler that worked fine in Windows 7, and is not working in Windows 10. Here's the code snippet: Dim myxlApplication, myWorkBook Set myxlApplication =…
cgc007
  • 25
  • 1
  • 7
1
vote
1 answer

Performance w/ Two Separate Instances of the Excel Application (VBA)

I have noticed that when using VBA to open different workbooks within another instance of the Excel application, large loops run much slower when reading data from the second application instance than if I simply bind the different workbooks to the…
1
vote
1 answer

Why am I getting a superfluous sheet even though I'm explicitly setting sheet count to 1?

I want to avoid generated spreadsheets having empty/superfluous sheets named "Sheet1" and such. I thought I could do that by specifying how many sheets a workbook should have this way: _xlApp = new Excel.Application { SheetsInNewWorkbook = 1…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
1
vote
1 answer

Open workbook unless it's already open autohotkey COM Object

I'm trying to check if an excel file is open, and if it is use the existing open file. If it's not, I want to open the file. This code just gives a blank msgbox: SetTitleMatchMode 2 xlWB := "MyExcelWorkbookTitle" if(!WinExist(xlWB)) { xl :=…
Jon
  • 239
  • 4
  • 15
1
vote
1 answer

Powershell add 1 to excel column reference

Just asked a powershell question here Finding excel cell reference and I need to add to it. The overall code I ended up with is as follows. $filePath = "c:\temp\test.xlsx" if (test-path $filePath) { $wb = $xl.Workbooks.Open($filePath) $ws =…
Silentbob
  • 2,805
  • 7
  • 38
  • 70
1
vote
3 answers

Close Open Excel Instance

Could someone please let me know if the following simple VBScript is correct? It is supposed to close Excel after other processes have run (and left Excel open), but it doesn't work. Set MyApp = CreateObject("Excel.Application") MyApp.Quit
1
vote
2 answers

How to close an application when vbscript crashes

I'm using VBscript to open Microsoft Excel and convert xls documents to csv. Here is a quick example that takes an argument and converts the first page Dim oExcel Dim oBook Set oExcel = CreateObject("Excel.Application") Set oBook =…
MxLDevs
  • 19,048
  • 36
  • 123
  • 194
0
votes
0 answers

win32com.client.Dispatch('Excel.Application') has stopped working

I have a process that clicks an Export button with pyautogui, and then waits for the Excel file to automatically open. This can take anything up to 10 seconds, so I wrote a small function so it waits for the Excel file to open. The meat of the…
ElJuanito
  • 13
  • 2
0
votes
0 answers

Weird issue when trying to open Excel Application from VBScript especially when the script is not running with elevated access/privileges

As I mentioned in the Q-title, I have a VBScript which I am sure was working fine in Windows 10 with Microsoft® Excel® LTSC MSO (Version 2205 Build 16.0.15225.20278) 64-bit Excel version and once I made sure that ClickToRunSvc service was running,…
Vicky Dev
  • 1,893
  • 2
  • 27
  • 62
1
2 3