Hi to everybody,
How to open the files otherthan .exe by using VB
can any body tell with example please
Thank u
3 7297
In your declarations at the top of the code, paste: - Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
And then use this function: - Public Function ShellExec(ByVal strFile As String)
-
Dim x As Long: x = ShellExecute(0, "OPEN", strFile, "", "", 0)
-
End Function
Passing the filepath as a parameter.
Hope that helps.
And the example you requested:
Private Sub cmdOpen_Click()
ShellExec("C:\testfile.doc")
End Sub
In your declarations at the top of the code, paste: - Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
And then use this function: - Public Function ShellExec(ByVal strFile As String)
-
Dim x As Long: x = ShellExecute(0, "OPEN", strFile, "", "", 0)
-
End Function
Passing the filepath as a parameter.
Hope that helps.
Woa, that's very nice. Sometimes I would be called Shell excute function, but Shell command in VB can't archive parameters with space character.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Bowling |
last post by:
I'm creating a routine (not in a browser) to move multiple files on a daily
basis to a backup directory. It can be done easily by call shell functions
like 'mv file* newdir'.
I can't find any...
|
by: Siemel Naran |
last post by:
Hi. I'm writing a command shell that reads commands from standard input.
At this point I have the command in a std::string. Now I want to execute
this command in the shell. From the Borland...
|
by: Lauren Wilson |
last post by:
Hi folks,
In an A2K app, I have attempted to use the following command in some
VBA code with IDENTICAL results with every single version of the
following:
Shell "outlook.exe", vbHide
Shell...
|
by: Mike |
last post by:
Am trying to open a Microsoft Word .doc file using Access 2000 with
Shell function (on Windows XP Operating system)
Here is the code :
Shell "C:\Program Files\Microsoft...
|
by: bearophileHUGS |
last post by:
For array.array "B" means unsigned char, and such arrays accept to be
initialized from (str) strings too, this is quite useful:
But it seems such capability isn't shared with the append:
...
|
by: George Sakkis |
last post by:
I'm trying to figure out why Popen captures the stderr of a specific
command when it runs through the shell but not without it. IOW:
cmd =
if 1: # this captures both stdout and stderr as...
|
by: Tom Gur |
last post by:
Hi,
It's seems that csh and tcsh acts a bit different when handling
special characters in quotes.
i.e: if i'll supply my program with the following arguments: -winpath
"c:\\temp\\"
tcsh will...
|
by: dennijr |
last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong
heres the simplist code possible:
Private Sub IExplorer_Click()
a = Shell("C:\Program...
|
by: mmm |
last post by:
I am looking for advice on Python Editors and IDEs
I have read other posts and threads on the subject and my two
questions at this time are mainly about the IDLE-like F5-run
facilities. While I...
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |