Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Shell function. Open Excel swtiches

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!)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Shell function. Open Excel swtiches

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


"IT_girl" wrote in message
...
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!)



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell - open document Jarle Excel Programming 6 April 8th 08 10:01 PM
Open document with Shell Jarle Excel Programming 1 April 4th 08 02:38 PM
Using Shell to open files with more than one word in their name Phil1982 Excel Programming 3 March 16th 06 09:26 PM
Using Shell to open files with more than one word in their name Tom Ogilvy Excel Programming 0 March 16th 06 06:55 PM
Shell to different app then open file within Justin[_12_] Excel Programming 0 November 30th 04 11:26 PM


All times are GMT +1. The time now is 01:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"