Dynamic Shell Function

ShuStar

Board Regular
Joined
Sep 9, 2015
Messages
89
Office Version
  1. 2010
Platform
  1. Windows
Hi, got my code all set up but require a dynamic shell function when calling notepad.

Currently it is as below (which works fine):

Call Shell("notepad C:\Users\Shudarstaran.Neel\Desktop\DummyTest.xml", vbNormalFocus)


I would like it to be dynamic and work like below:

Call Shell ("notepad ActiveSheet.Range("KL3") & ActiveSheet.Range("KL4") & ".xml",vbNormal Focus)
application filepath filename


I'll be using this on multiple codes so the easiest way would be great if anyone knows.

Any pointers?

ShuStar
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
First of all I think you need the quotes below

Code:
("notepad [COLOR="#FF0000"]"[/COLOR] &  ActiveSheet.Range("KL3") & ActiveSheet.Range("KL4") & ".xml",vbNormal Focus)

Also what exactly are the contents of KL3 and KL4 including do you have all the backslashes in the cells?
 
Upvote 0
Nope it doesnt seem to like that. Gives me a compile error "Expected: list separator or )" message pops up highlighting ..Range("KL3").

Yep the backslashes exist in all the cells as needed when creating a standard pathway
KL3 = File path
KL4 = File name

Call Shell ("notepad " & ActiveSheet.Range("KL3") & ActiveSheet.Range("KL4") & ".xml",vbNormal Focus) does not work... any other resolutions i can try maybe?

ShuStar
 
Upvote 0
KL3 = File path
KL4 = File name

No, I asked
Code:
 what [B][COLOR="#FF0000"]exactly [/COLOR][/B]are the contents of KL3 and KL4
not what the contents represent.


and
Code:
Sub ccc()
Call Shell("notepad " & ActiveSheet.Range("KL3") & ActiveSheet.Range("KL4") & ".xml", vbNormalFocus)
End Sub

gives me no syntax error with


Excel 2010
KL
3C:\Users\Shudarstaran.Neel\Desktop\
4DummyTest
Sheet2
 
Last edited:
Upvote 0
Apologies, yep you got the content right. I've tried your code again and its working fine now, spaces and speech marks was the issue. :rolleyes:

Such a simple fix but incredibly frustrating!! Awesome stuff, thanks for your help.

ShuStar
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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