Visual Basic Commands help required

  • Thread starter Chetan R Jobanputra
  • Start date

Thread Starter

Chetan R Jobanputra

Can anybody guide what is the command in visual basic for

(1) Opening any file from VB Project ,like *.xls, *.doc, etc.
such as for *.exe file to open we can use shell command as below.

Dim RetVal

RetVal = Shell("C:\Program Files\Microsoft

(2) Linking with database application using source code.

such as database file : c:\abcd\data.mdb
in this table name : Aromatics
in this table ,column name : Inst. Tag No.

All the records in this column we have to link such that after giving command this record should displayed.

[email protected]

Robert Vestal

If I understand your question that you want to open a mdb file from within VB and have the database open to a particular record based on a passed value.
Well one way that might work, even though I haven't tried it per se, but I have done something similar.

Dim vAppID as Variant

vAppID= Shell("C:\...\msaccess.exe_C:\...\file.mdb_/cmdXX",3)
in the above string the _ represents a space.
Within Access, you must create an autoexec file that will take the value after the /cmd (XX above) and then run a script that filters for that value in a query.

Francis Lovering

Try this:
'Declare a database object
dim MyDB as database
'Declare a recordset object
dim recs as recordset
'Open the database
set MyDB = opendatabase("c:\abcd\data.mdb")
'Open the table
set recs = MyDB.openrecordset("SELECT * FROM Aromatic", vbOpenDydnaset)
'now you can mode through the records with commands like
Recs.findfirst "Tagno = PIC123"

'and you can edit records with commands like
recs!Tagno = "AnotherTag"

'when finished you should close the database
set recs = nothing
set set recs = nothing

I suggest you look at

Darryl L. Palmer

For the first question.

To start an application by specifying a filename without having to know the name of the associated program, the command you want is ShellExecute not
Shell. ShellExecute is a Win32 API call and there is no VB version of this function. You have to declare the function and what DLL it is associated with in your Visual Basic code and handle the parameters to call it. The
knowledge base for Visual Basic shows how to do it, look for ID: Q170918. The title is "HOWTO: Use ShellExecute to Launch Associated File (32-bit)".

Darryl Palmer
Cleveland State University

Brandon Ellis


I would recommend you go to the Microsoft Newsgroups (select the VB discussion group) on . These groups handle questions like this all the time.

I can tell you, however, that there is no native VB command to open a *.doc with its associated executable, but there are methods of doing this with the WIN32 API commands that you can use
within VB. This is a common question in the Microsoft Newsgroups, so you should be able to find an answer rather easily.

I hope this helps,

Brandon S. Ellis
Sales Manager
Robotic Control Group
700 S. Illinois Ave.
Suite A104
Oak Ridge, TN 37830
Tel: (865) 425-0301, Ext. 160
Fax: (865) 425-0268

Marcello Savona

Try using the ADO object of Microsoft VB.
There are many features associated with this object. They are also very easy to use as they can be visually done.
You can try using the ADO object of Microsoft VB. Otherwise go and see "HOWTO: Use ShellExecute to Launch Associated File (32-bit)". in microsoft knowledge based search

desperate student from cambridge uk.

if you get any where please share ur knowledge. ive been trying for ages and ive had no luck, so please can u help me!!!