Home All Groups Group Topic Archive Search About

Get Selected Path From Explorer

Author
2 Aug 2010 4:16 AM
David
Using XP:

Writing a quick editing program where I want to select the
file in Windows Explorer, right click and bring up a menu, select my
program and have it open the file that was selected in Windows Explorer.

All internet searches to get the File name and Path from Windows Explorer
have failed.   Have thought about trying to extract the path from the
combobox which
appears at the top of Windows Explorer, but seems to be a long way around
the block.

Anyone have a solution to getting the File Name and Path from Windows
Explorer for use in a VB program?

Author
2 Aug 2010 5:24 AM
Nobody
Show quote Hide quote
"David" <NoWh***@earthlink.net> wrote in message
news:uoKc8lfMLHA.1996@TK2MSFTNGP06.phx.gbl...
>
> Using XP:
>
> Writing a quick editing program where I want to select the
> file in Windows Explorer, right click and bring up a menu, select my
> program and have it open the file that was selected in Windows Explorer.
>
> All internet searches to get the File name and Path from Windows Explorer
> have failed.   Have thought about trying to extract the path from the
> combobox which
> appears at the top of Windows Explorer, but seems to be a long way around
> the block.
>
> Anyone have a solution to getting the File Name and Path from Windows
> Explorer for use in a VB program?

If you made the registry entries or file association correctly, then the
file name is in the command line. See "Command function" in MSDN in how to
get the command line. Example:

MsgBox Command()
Author
2 Aug 2010 9:58 AM
Larry Serflaten
Show quote Hide quote
"David" <NoWh***@earthlink.net> wrote

> Using XP:
>
> Writing a quick editing program where I want to select the
> file in Windows Explorer, right click and bring up a menu, select my
> program and have it open the file that was selected in Windows Explorer.
>
> All internet searches to get the File name and Path from Windows Explorer
> have failed.   Have thought about trying to extract the path from the
> combobox which
> appears at the top of Windows Explorer, but seems to be a long way around
> the block.
>
> Anyone have a solution to getting the File Name and Path from Windows
> Explorer for use in a VB program?


Use the Command function to get the command line that was used to start
your program:

Sub Main()
  MsgBox Command()
End Sub

Create your EXE and create a shortcut to it in your SendTo folder.

Select a file in Explorer, right click for the menu and select Send To...
Then select the shortcut you put there....

LFS
Author
2 Aug 2010 1:19 PM
Mayayana
I'm guessing that Nobody and Larry already provided
the answer you need. If you really do need to access
the Explorer window....
  You need to get a ShellFolderView object for the
window (via API or via the Shell Windows collection),
which is a wrapper around the ListView that
shows the folder content. SFV has a SelectedItems,
which is a FolderItems collection containing the current
selection(s) as FolderItems. FolderItem has a Path
property.



Show quoteHide quote
| Using XP:
|
| Writing a quick editing program where I want to select the
| file in Windows Explorer, right click and bring up a menu, select my
| program and have it open the file that was selected in Windows Explorer.
|
| All internet searches to get the File name and Path from Windows Explorer
| have failed.   Have thought about trying to extract the path from the
| combobox which
| appears at the top of Windows Explorer, but seems to be a long way around
| the block.
|
| Anyone have a solution to getting the File Name and Path from Windows
| Explorer for use in a VB program?
|
|
Author
2 Aug 2010 3:10 PM
David
Thanks all.  Will give it a go and post back this thread if issues.
Have a nice day.
David

Show quoteHide quote
"Mayayana" <mayayana@invalid.nospam> wrote in message
news:i36ghj$dif$1@news.eternal-september.org...
> I'm guessing that Nobody and Larry already provided
> the answer you need. If you really do need to access
> the Explorer window....
>  You need to get a ShellFolderView object for the
> window (via API or via the Shell Windows collection),
> which is a wrapper around the ListView that
> shows the folder content. SFV has a SelectedItems,
> which is a FolderItems collection containing the current
> selection(s) as FolderItems. FolderItem has a Path
> property.
>
>
>
> | Using XP:
> |
> | Writing a quick editing program where I want to select the
> | file in Windows Explorer, right click and bring up a menu, select my
> | program and have it open the file that was selected in Windows Explorer.
> |
> | All internet searches to get the File name and Path from Windows
> Explorer
> | have failed.   Have thought about trying to extract the path from the
> | combobox which
> | appears at the top of Windows Explorer, but seems to be a long way
> around
> | the block.
> |
> | Anyone have a solution to getting the File Name and Path from Windows
> | Explorer for use in a VB program?
> |
> |
>
>
Author
6 Aug 2010 6:27 PM
David
Hope this may help others.

The solution I came up with was to create a right menu option
installer using the following:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]

@="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]

@="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""

====================================

The UnInstaller if needed is:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path]



[-HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path]

==========================================

I then wrote a VB6 program (ChgPicPath.exe) which obtaines the Explorer Path
using:

Dim strExplorerPath As String

strExplorerPath = Command

========================================

Once the Path is obtained you can do what you want to with it on your
program (in my case ChgPicPath.exe)

================================

Note: When using a Registry entry to create a Right Menu Click it will ONLY
work with a compilere file ".exe".

It will NOT work from the VB IDE.







Show quoteHide quote
"Mayayana" <mayayana@invalid.nospam> wrote in message
news:i36ghj$dif$1@news.eternal-september.org...
> I'm guessing that Nobody and Larry already provided
> the answer you need. If you really do need to access
> the Explorer window....
>  You need to get a ShellFolderView object for the
> window (via API or via the Shell Windows collection),
> which is a wrapper around the ListView that
> shows the folder content. SFV has a SelectedItems,
> which is a FolderItems collection containing the current
> selection(s) as FolderItems. FolderItem has a Path
> property.
>
>
>
> | Using XP:
> |
> | Writing a quick editing program where I want to select the
> | file in Windows Explorer, right click and bring up a menu, select my
> | program and have it open the file that was selected in Windows Explorer.
> |
> | All internet searches to get the File name and Path from Windows
> Explorer
> | have failed.   Have thought about trying to extract the path from the
> | combobox which
> | appears at the top of Windows Explorer, but seems to be a long way
> around
> | the block.
> |
> | Anyone have a solution to getting the File Name and Path from Windows
> | Explorer for use in a VB program?
> |
> |
>
>
Author
6 Aug 2010 8:38 PM
MikeD
Show quote Hide quote
"David" <NoWh***@earthlink.net> wrote in message
news:OwBYPUZNLHA.5624@TK2MSFTNGP02.phx.gbl...
>
> The solution I came up with was to create a right menu option
> installer using the following:
>
> Windows Registry Editor Version 5.00
>
> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
>
> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>
> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
>
> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>
> It will NOT work from the VB IDE.

Sure it will, with a little effort and know-how. The know-how involves using
VB6's own command line parameters. The first step would be to substitute the
path to VB AND to your project in the above Registry entries. Be sure to use
separate quotation marks around EACH. Include the path and file name of your
project AND include the /cmd command line parameter.  What this parameter
does is load whatever command line parameters are passed into the Command
Line Arguments field in Project Properties. The result is that whatever is
represented by %1 will be in Command Line Arguments.  For example, your
Registry entry might look like this (I might have the actual syntax wrong
(probably easier to do this using RegEdit):

@="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change HTML
File Path\\ChgPicPath.vbp\" /cmd \"%1\""

-----
if using RegEdit, what you'd type in is this line (using the proper paths
and file names, of course):
"D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
Path\ChgPicPath.vbp" /cmd "%1"
-----

Now, do your right-click on the file and select your context menu command.
VB will launch and load your project.  Open Project Properties, go to the
Make tab and look at the Command Line Arguments box.  It'll have the path
and file name of the file you right-clicked.  Now you can just press F5 to
run your project in the IDE, or set break points or press F8 to begin
stepping through code, etc., etc., etc.

Obviously, it'd be easier to just open the project "normally" and add the
path and file name to Command Line Arguments, but this doesn't test actually
right-clicking the file and selecting the command. But once you've verified
that part "works", there's no need to test that part further.

--
Mike

P.S.  To see all of VB6's command line options (you might want to use the
/run or /runexit parameters with this), run VB6.exe with the parameter /?.
For example:

"D:\Visual Studio 6\VB98\VB6.exe" /?
Author
7 Aug 2010 10:25 PM
David
As always thanks for yours and everyone help.
Greatly appreciated.

//////////////////////////////////////////////////////////////
Haven't tried your IDE example yet.
Before that I have a couple questions related to using a "exe" rather than
from the IDE.

When I compile and right click my program I'm failing on:

   Open szFileName For Input As #1

   with Error 52, Bad File Name.

When I run the compiled program with a hardcoded string and
output that string and the various string parts (Path, FileName + Ext,
FileNameOnly) to label controls, NO quotes appear around the strings.

However when I use  "Command" in the compiled program  rather than a hard
coded string, and again output the various string parts to label controls, a
quote mark appears at the beginning or end of the various label captions.

So, I'm starting to believe that using "Command" with VB combined with
Explorer may return a different string type which is what is causing me to
error with Bad File Name.

Code follows:

Any Input appreciated.

David

///////////////////////////////////////////

   '*******
   'STARTUP
   '*******
   Label1.Caption = "junk1"
   Label2.Caption = "junk2"
   Label3.Caption = "junk3"
   Label4.Caption = "junk4"

   '*****
   'MAIN
   '*****
   'Get File Name and Path from Explorer
   '  Path is on the "Command" line once the file is selected
   strExplorerPath = Command

'hard coded now remmed
'   strExplorerPath = "D:\VB
Modules\Explorer\Samples\RightClickMenuCopy\MenuGetPath2Copy.htm"

   'Try trimming
   strExplorerPath = Trim$(strExplorerPath)

   'Break the Path from Explorer Apart
   strFilePath = MPath.GetFilePath(strExplorerPath)
   strFileNameEx = MPath.GetFileName(strExplorerPath)
   strFileName = MPath.GetFileNameOnly(strExplorerPath)


Form1.Caption = strExplorerPath
Label1.Caption = strExplorerPath
Label2.Caption = strFilePath
Label3.Caption = strFileNameEx
Label4.Caption = strFileName


Exit Sub





Show quoteHide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:i3hrrt$udr$1@news.eternal-september.org...
> "David" <NoWh***@earthlink.net> wrote in message
> news:OwBYPUZNLHA.5624@TK2MSFTNGP02.phx.gbl...
>>
>> The solution I came up with was to create a right menu option
>> installer using the following:
>>
>> Windows Registry Editor Version 5.00
>>
>> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
>>
>> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>>
>> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
>>
>> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>>
>> It will NOT work from the VB IDE.
>
> Sure it will, with a little effort and know-how. The know-how involves
> using VB6's own command line parameters. The first step would be to
> substitute the path to VB AND to your project in the above Registry
> entries. Be sure to use separate quotation marks around EACH. Include the
> path and file name of your project AND include the /cmd command line
> parameter.  What this parameter does is load whatever command line
> parameters are passed into the Command Line Arguments field in Project
> Properties. The result is that whatever is represented by %1 will be in
> Command Line Arguments.  For example, your Registry entry might look like
> this (I might have the actual syntax wrong (probably easier to do this
> using RegEdit):
>
> @="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change HTML
> File Path\\ChgPicPath.vbp\" /cmd \"%1\""
>
> -----
> if using RegEdit, what you'd type in is this line (using the proper paths
> and file names, of course):
> "D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
> Path\ChgPicPath.vbp" /cmd "%1"
> -----
>
> Now, do your right-click on the file and select your context menu command.
> VB will launch and load your project.  Open Project Properties, go to the
> Make tab and look at the Command Line Arguments box.  It'll have the path
> and file name of the file you right-clicked.  Now you can just press F5 to
> run your project in the IDE, or set break points or press F8 to begin
> stepping through code, etc., etc., etc.
>
> Obviously, it'd be easier to just open the project "normally" and add the
> path and file name to Command Line Arguments, but this doesn't test
> actually right-clicking the file and selecting the command. But once
> you've verified that part "works", there's no need to test that part
> further.
>
> --
> Mike
>
> P.S.  To see all of VB6's command line options (you might want to use the
> /run or /runexit parameters with this), run VB6.exe with the parameter /?.
> For example:
>
> "D:\Visual Studio 6\VB98\VB6.exe" /?
>
>
Author
8 Aug 2010 12:51 AM
Kevin Provance
Look up FreeFile, and whip up a FileExists routine before you open a file to
avoid such errors.

--
Customer Hatred Knows No Bounds at MSFT
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Bawwk!  Paulie want a dingleball, bawwk!
Show quoteHide quote
"David" <NoWh***@earthlink.net> wrote in message
news:uncf49nNLHA.1868@TK2MSFTNGP05.phx.gbl...
: As always thanks for yours and everyone help.
: Greatly appreciated.
:
: //////////////////////////////////////////////////////////////
: Haven't tried your IDE example yet.
: Before that I have a couple questions related to using a "exe" rather than
: from the IDE.
:
: When I compile and right click my program I'm failing on:
:
:   Open szFileName For Input As #1
:
:   with Error 52, Bad File Name.
:
: When I run the compiled program with a hardcoded string and
: output that string and the various string parts (Path, FileName + Ext,
: FileNameOnly) to label controls, NO quotes appear around the strings.
:
: However when I use  "Command" in the compiled program  rather than a hard
: coded string, and again output the various string parts to label controls,
a
: quote mark appears at the beginning or end of the various label captions.
:
: So, I'm starting to believe that using "Command" with VB combined with
: Explorer may return a different string type which is what is causing me to
: error with Bad File Name.
:
: Code follows:
:
: Any Input appreciated.
:
: David
:
: ///////////////////////////////////////////
:
:   '*******
:   'STARTUP
:   '*******
:   Label1.Caption = "junk1"
:   Label2.Caption = "junk2"
:   Label3.Caption = "junk3"
:   Label4.Caption = "junk4"
:
:   '*****
:   'MAIN
:   '*****
:   'Get File Name and Path from Explorer
:   '  Path is on the "Command" line once the file is selected
:   strExplorerPath = Command
:
: 'hard coded now remmed
: '   strExplorerPath = "D:\VB
: Modules\Explorer\Samples\RightClickMenuCopy\MenuGetPath2Copy.htm"
:
:   'Try trimming
:   strExplorerPath = Trim$(strExplorerPath)
:
:   'Break the Path from Explorer Apart
:   strFilePath = MPath.GetFilePath(strExplorerPath)
:   strFileNameEx = MPath.GetFileName(strExplorerPath)
:   strFileName = MPath.GetFileNameOnly(strExplorerPath)
:
:
: Form1.Caption = strExplorerPath
: Label1.Caption = strExplorerPath
: Label2.Caption = strFilePath
: Label3.Caption = strFileNameEx
: Label4.Caption = strFileName
:
:
: Exit Sub
:
:
:
:
:
: "MikeD" <nob***@nowhere.edu> wrote in message
: news:i3hrrt$udr$1@news.eternal-september.org...
: > "David" <NoWh***@earthlink.net> wrote in message
: > news:OwBYPUZNLHA.5624@TK2MSFTNGP02.phx.gbl...
: >>
: >> The solution I came up with was to create a right menu option
: >> installer using the following:
: >>
: >> Windows Registry Editor Version 5.00
: >>
: >> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
: >>
: >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
: >>
: >> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
: >>
: >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
: >>
: >> It will NOT work from the VB IDE.
: >
: > Sure it will, with a little effort and know-how. The know-how involves
: > using VB6's own command line parameters. The first step would be to
: > substitute the path to VB AND to your project in the above Registry
: > entries. Be sure to use separate quotation marks around EACH. Include
the
: > path and file name of your project AND include the /cmd command line
: > parameter.  What this parameter does is load whatever command line
: > parameters are passed into the Command Line Arguments field in Project
: > Properties. The result is that whatever is represented by %1 will be in
: > Command Line Arguments.  For example, your Registry entry might look
like
: > this (I might have the actual syntax wrong (probably easier to do this
: > using RegEdit):
: >
: > @="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change HTML
: > File Path\\ChgPicPath.vbp\" /cmd \"%1\""
: >
: > -----
: > if using RegEdit, what you'd type in is this line (using the proper
paths
: > and file names, of course):
: > "D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
: > Path\ChgPicPath.vbp" /cmd "%1"
: > -----
: >
: > Now, do your right-click on the file and select your context menu
command.
: > VB will launch and load your project.  Open Project Properties, go to
the
: > Make tab and look at the Command Line Arguments box.  It'll have the
path
: > and file name of the file you right-clicked.  Now you can just press F5
to
: > run your project in the IDE, or set break points or press F8 to begin
: > stepping through code, etc., etc., etc.
: >
: > Obviously, it'd be easier to just open the project "normally" and add
the
: > path and file name to Command Line Arguments, but this doesn't test
: > actually right-clicking the file and selecting the command. But once
: > you've verified that part "works", there's no need to test that part
: > further.
: >
: > --
: > Mike
: >
: > P.S.  To see all of VB6's command line options (you might want to use
the
: > /run or /runexit parameters with this), run VB6.exe with the parameter
/?.
: > For example:
: >
: > "D:\Visual Studio 6\VB98\VB6.exe" /?
: >
: >
:
:
Author
8 Aug 2010 2:47 AM
David
Mr. Provance:

That's "Not" where the problem is coming from.
After a lot work, it appears Command is returning a string with
quotes delimited around it while a normal VB string is shown without.
Displayed both to labels and that  is the difference showing.

However, after removing both quotes (beginning and ending)
rather than Err 52 (Bad File Name).  The program locks big time.

So OBVIOUSLY I'm doing something wrong by getting the file name
in VB using Command from Explorer and then trying to search
and replace within that file name from VB using a Right Context Menu.

Any ideas??.



Show quoteHide quote
"Kevin Provance" <k@p.c> wrote in message
news:i3kv1p$82e$1@news.eternal-september.org...
> Look up FreeFile, and whip up a FileExists routine before you open a file
> to
> avoid such errors.
>
> --
> Customer Hatred Knows No Bounds at MSFT
> Free usenet access at http://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
> Bawwk!  Paulie want a dingleball, bawwk!
> "David" <NoWh***@earthlink.net> wrote in message
> news:uncf49nNLHA.1868@TK2MSFTNGP05.phx.gbl...
> : As always thanks for yours and everyone help.
> : Greatly appreciated.
> :
> : //////////////////////////////////////////////////////////////
> : Haven't tried your IDE example yet.
> : Before that I have a couple questions related to using a "exe" rather
> than
> : from the IDE.
> :
> : When I compile and right click my program I'm failing on:
> :
> :   Open szFileName For Input As #1
> :
> :   with Error 52, Bad File Name.
> :
> : When I run the compiled program with a hardcoded string and
> : output that string and the various string parts (Path, FileName + Ext,
> : FileNameOnly) to label controls, NO quotes appear around the strings.
> :
> : However when I use  "Command" in the compiled program  rather than a
> hard
> : coded string, and again output the various string parts to label
> controls,
> a
> : quote mark appears at the beginning or end of the various label
> captions.
> :
> : So, I'm starting to believe that using "Command" with VB combined with
> : Explorer may return a different string type which is what is causing me
> to
> : error with Bad File Name.
> :
> : Code follows:
> :
> : Any Input appreciated.
> :
> : David
> :
> : ///////////////////////////////////////////
> :
> :   '*******
> :   'STARTUP
> :   '*******
> :   Label1.Caption = "junk1"
> :   Label2.Caption = "junk2"
> :   Label3.Caption = "junk3"
> :   Label4.Caption = "junk4"
> :
> :   '*****
> :   'MAIN
> :   '*****
> :   'Get File Name and Path from Explorer
> :   '  Path is on the "Command" line once the file is selected
> :   strExplorerPath = Command
> :
> : 'hard coded now remmed
> : '   strExplorerPath = "D:\VB
> : Modules\Explorer\Samples\RightClickMenuCopy\MenuGetPath2Copy.htm"
> :
> :   'Try trimming
> :   strExplorerPath = Trim$(strExplorerPath)
> :
> :   'Break the Path from Explorer Apart
> :   strFilePath = MPath.GetFilePath(strExplorerPath)
> :   strFileNameEx = MPath.GetFileName(strExplorerPath)
> :   strFileName = MPath.GetFileNameOnly(strExplorerPath)
> :
> :
> : Form1.Caption = strExplorerPath
> : Label1.Caption = strExplorerPath
> : Label2.Caption = strFilePath
> : Label3.Caption = strFileNameEx
> : Label4.Caption = strFileName
> :
> :
> : Exit Sub
> :
> :
> :
> :
> :
> : "MikeD" <nob***@nowhere.edu> wrote in message
> : news:i3hrrt$udr$1@news.eternal-september.org...
> : > "David" <NoWh***@earthlink.net> wrote in message
> : > news:OwBYPUZNLHA.5624@TK2MSFTNGP02.phx.gbl...
> : >>
> : >> The solution I came up with was to create a right menu option
> : >> installer using the following:
> : >>
> : >> Windows Registry Editor Version 5.00
> : >>
> : >> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
> : >>
> : >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\"
> \"%1\""
> : >>
> : >> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
> : >>
> : >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\"
> \"%1\""
> : >>
> : >> It will NOT work from the VB IDE.
> : >
> : > Sure it will, with a little effort and know-how. The know-how involves
> : > using VB6's own command line parameters. The first step would be to
> : > substitute the path to VB AND to your project in the above Registry
> : > entries. Be sure to use separate quotation marks around EACH. Include
> the
> : > path and file name of your project AND include the /cmd command line
> : > parameter.  What this parameter does is load whatever command line
> : > parameters are passed into the Command Line Arguments field in Project
> : > Properties. The result is that whatever is represented by %1 will be
> in
> : > Command Line Arguments.  For example, your Registry entry might look
> like
> : > this (I might have the actual syntax wrong (probably easier to do this
> : > using RegEdit):
> : >
> : > @="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change
> HTML
> : > File Path\\ChgPicPath.vbp\" /cmd \"%1\""
> : >
> : > -----
> : > if using RegEdit, what you'd type in is this line (using the proper
> paths
> : > and file names, of course):
> : > "D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
> : > Path\ChgPicPath.vbp" /cmd "%1"
> : > -----
> : >
> : > Now, do your right-click on the file and select your context menu
> command.
> : > VB will launch and load your project.  Open Project Properties, go to
> the
> : > Make tab and look at the Command Line Arguments box.  It'll have the
> path
> : > and file name of the file you right-clicked.  Now you can just press
> F5
> to
> : > run your project in the IDE, or set break points or press F8 to begin
> : > stepping through code, etc., etc., etc.
> : >
> : > Obviously, it'd be easier to just open the project "normally" and add
> the
> : > path and file name to Command Line Arguments, but this doesn't test
> : > actually right-clicking the file and selecting the command. But once
> : > you've verified that part "works", there's no need to test that part
> : > further.
> : >
> : > --
> : > Mike
> : >
> : > P.S.  To see all of VB6's command line options (you might want to use
> the
> : > /run or /runexit parameters with this), run VB6.exe with the parameter
> /?.
> : > For example:
> : >
> : > "D:\Visual Studio 6\VB98\VB6.exe" /?
> : >
> : >
> :
> :
>
Author
8 Aug 2010 7:26 AM
Mike S
On 8/7/2010 7:47 PM, David wrote:
Show quoteHide quote
> Mr. Provance:
>
> That's "Not" where the problem is coming from.
> After a lot work, it appears Command is returning a string with
> quotes delimited around it while a normal VB string is shown without.
> Displayed both to labels and that  is the difference showing.
>
> However, after removing both quotes (beginning and ending)
> rather than Err 52 (Bad File Name).  The program locks big time.
>
> So OBVIOUSLY I'm doing something wrong by getting the file name
> in VB using Command from Explorer and then trying to search
> and replace within that file name from VB using a Right Context Menu.
>
> Any ideas??.

Please show the string Command is receiving, the string you're working
with, and the code that uses the string.
Author
8 Aug 2010 7:28 AM
Larry Serflaten
Show quote Hide quote
"David" <NoWh***@earthlink.net> wrote
>
> That's "Not" where the problem is coming from.
> After a lot work, it appears Command is returning a string with
> quotes delimited around it while a normal VB string is shown without.
> Displayed both to labels and that  is the difference showing.
>
> However, after removing both quotes (beginning and ending)
> rather than Err 52 (Bad File Name).  The program locks big time.
>
> So OBVIOUSLY I'm doing something wrong by getting the file name
> in VB using Command from Explorer and then trying to search
> and replace within that file name from VB using a Right Context Menu.
>
> Any ideas??.

Don't be so sure what is and isn't obvious, you might find a simple
typo wreaks havok in your code.  For example, is Option Explicit the
first line in all your code modules?  If not, make it so and try again.

If your program works when you hard code a string, but not when
you use the Command function, then something is wrong with your
handling of the Command function.  Are you sure you are getting only
one file name?  Have you double checked your ability to remove the
quotes on either end?  Do you test to be sure what you end up with is
a valid file name?  etc..  etc....

Programs don't fall into place, you have to put every letter exactly in
place for the thing to run.  Likewise you should check your data to
be sure it is exactly what you expect all through the process.

LFS
Author
8 Aug 2010 4:58 PM
David
Thanks all for the help.

First let me thank everyone for their assistance.  Greatly appreciated.

For what I thought would take me an hour to write a simple program to
substitute the
current folder on my system for the embedded folder associated with a image
on
a downloaded web page has turned into a good reminder of "Murray's Law".

That said, it appears I may be dealing with two issues.

1)  Getting a file string from Explorer from VB using the Command line
function where the file name contains spaces.

     In this instance stripping the quotes from the beginning and end of the
file name that is returned on the
     command line "appears" (juries still out) to resolve the issue.
This was determined by hard coding the directory then sending it to a label
as well as sending the string returned from command to another label.

Further internet research seems to confirm this fact.


[CODE]

   strExplorerPath = Command$()

   'The Command Line returns a string with quotes on
   'beginning and end.  These need to be removed otherwise
   'fails as string
   'Strip right quote character
   If Right$(strExplorerPath, 1) = Chr$(34) Then
      strExplorerPath = Left$(strExplorerPath, Len(strExplorerPath) - 1)
   End If

   'Strip left quote character
   If Left$(strExplorerPath, 1) = Chr$(34) Then
      strExplorerPath = Right$(strExplorerPath, Len(strExplorerPath) - 1)
   End If

[/CODE]

2)  The second issue:
      I just happened to download a second web page to use for testing
     that contains some type of scheme to keep a search/replace program from
altering the
     htm file (my luck).
     So I need to spend some time figuring out what was done and how to beat
it as I'm sure
     it may be used more than just the web page I picked.

Consequently, I am closing this thread.




Show quoteHide quote
"Larry Serflaten" <serfla***@gmail.com> wrote in message
news:i3lma4$g9e$1@news.eternal-september.org...
>
> "David" <NoWh***@earthlink.net> wrote
>>
>> That's "Not" where the problem is coming from.
>> After a lot work, it appears Command is returning a string with
>> quotes delimited around it while a normal VB string is shown without.
>> Displayed both to labels and that  is the difference showing.
>>
>> However, after removing both quotes (beginning and ending)
>> rather than Err 52 (Bad File Name).  The program locks big time.
>>
>> So OBVIOUSLY I'm doing something wrong by getting the file name
>> in VB using Command from Explorer and then trying to search
>> and replace within that file name from VB using a Right Context Menu.
>>
>> Any ideas??.
>
> Don't be so sure what is and isn't obvious, you might find a simple
> typo wreaks havok in your code.  For example, is Option Explicit the
> first line in all your code modules?  If not, make it so and try again.
>
> If your program works when you hard code a string, but not when
> you use the Command function, then something is wrong with your
> handling of the Command function.  Are you sure you are getting only
> one file name?  Have you double checked your ability to remove the
> quotes on either end?  Do you test to be sure what you end up with is
> a valid file name?  etc..  etc....
>
> Programs don't fall into place, you have to put every letter exactly in
> place for the thing to run.  Likewise you should check your data to
> be sure it is exactly what you expect all through the process.
>
> LFS
>
>