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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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