Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB3, VB4, VB5, VB6
Expertise: Beginner
Jul 25, 2003

Copy Filenames to a Clipboard

File hierarchies are becoming more complex and file paths longer as the capacity of hard drives increases. There are still many occasions, however, when you can't browse to identify a file to be used—for example, when entering a constant in VB source. Normally, there is no alternative but to type in the path—this can be both tiresome and error-prone.

The solution: Create a new Standard EXE project, delete the default form (Form1), and add a module (Module1 by default). Type this code into Module1:


Sub Main()
	Clipboard.SetText Command$
End Sub
Under Project | Project Properties, set the Startup Object to Sub Main. Give the project a suitable name (for example, filename) and create the executable (in this case, filename.exe). Create a shortcut to the executable on your desktop. When the name of file is required, browse using Explorer or My Computer. Drag the file and drop it onto the filename shortcut. The full path of the file is now on the clipboard and you can paste it as necessary.

This works because dropping an object onto a program or its shortcut starts it with the name of the object in the command line. The program merely reads the command line and puts it onto the clipboard.

M.J. Roycroft
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date