Shell function. Open Excel swtiches

I

IT_girl

I've written some vba code (in my 'Control Panel') that uses the Shell
function to open another instance of Excel which opens 'Report.xls'
that process some stuff (pivot table refreshes etc) for a few mins
then closes. I'll eventually want a few of these instances opening
concurrently.

This is the code i used:
Shell "C:\Program Files\Microsoft Office\OFFICE11\Excel.exe C:\Folder
\Report.xls", vbMinimizedNoFocus


My problem is that 'Personal.xls' is getting in the way. When the new
instance of Excel opens, how do I handle (in code) the message that
says "Personal.xls locked for editing. Read Only, Notify, Cancel".

I thought of moving Personal.xls out of my XLStart folder and only
opening it when i need it, but i need it all the time.

I know that there are switches you can use but none of them (that i
know of) seem appropriate. (see examples below) Opening a 'blank'
session with /e doesn't work because it still opens Personal.xls.
Opening in safe mode with /s doesn't open Personal.xls but it also
won't allow me to run the macros I need to run in 'Report.xls'.

Shell "C:\Program Files\Microsoft Office\OFFICE11\Excel.exe /e C:
\Folder\PivotReport.xls", vbMinimizedNoFocus

Shell "C:\Program Files\Microsoft Office\OFFICE11\Excel.exe /s C:
\Folder\PivotReport.xls", vbMinimizedNoFocus


Any ideas anyone?
Thanks in advance!!
(this is my very first post, I can usually find answers by looking at
other people's posts but not this time!)
 
P

Peter T

You may need to explain what you mean by this -
I've written some vba code (in my 'Control Panel')

VBA code exists in an application that can host a VB_IDE, or do you mean
visual basic script.

Where ever the code is, if you start Excel with Automation rather than with
Shell, neither Personal nor any installed addins will automatically load (if
they are required need to load explicitly).

If your VBA is in Excel try this -

Sub test()
Dim xlApp As Application
Dim sFile As String

sFile = "C:\path\myFile.xls"

Set xlApp = New Excel.Application
xlApp.Workbooks.Open sFile
xlApp.Visible = True

End Sub


If your code is in some other application change

Dim xlApp As Application
Set xlApp = New Excel.Application

to
Dim xlApp as Object
Set xlApp = CreateObject("excel.application")
I'll eventually want a few of these instances opening
concurrently.

I doubt that's necessary. Why not do all your VBA processing in the same
instance.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top