Command Prompt Opening Excel

rahulbassi

Board Regular
Joined
Aug 14, 2011
Messages
130
Hello Team,

I'm opening excel file from command prompt using below command:

Code:
start excel.exe "D:\Temp\MyFile.xls" /e/%SR%-%CR%

SR and CR are two arguments being passed.

When Excel files open, I'm checking if it is being opened by command prompt or by user manually. This helps me decide if to expect arguments or not.

Code:
CmdRaw = GetCommandLine
    CmdLine = CmdToSTr(CmdRaw)
    
   If Right(CmdLine, 3) = "dde" Then
        'Not Opened from Batch File
        'Do Nothing
   Else
    'Opened from Batch File
    'Capture the SR and CR Numbers
End If

The problem is when opened by user manually. The file opens without Error if there is No other excel file already opened. It stays in IF block.

But, If there is some other excel file already opened and user tries to open this file, it goes into Else Part.

Can you please suggest.

Thanks,
Rahul
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top