Question:
how to link an application in visual basic?
faLLoutGirL
2008-12-04 06:27:29 UTC
the MS word, excel, powerpoint can be seen in one application using visual basic...can you please give some instructions how to link or rather call them in visual basic?
Four answers:
anonymous
2008-12-04 06:49:05 UTC
Your question is nearly bogus. I'll give you the answer that I think you want, but for future reference, try to read what you post prior to posting it. Not to try and sound like the "post police", but damn you sound ignorant. It's amazing you know what VB is...



Here' a command to make a button that will launch a program:



Private Sub CommandButton1_Click()

Shell "C:\Windows\Stupid.exe", vbMaximizedFocus

End Sub



Here's a command to make a button that will launch a streaming windows media player link from a specific host (port number not truly necessary unless you're doing some renegade type of stuff. I use Microsoft Expression Encoder to launch a local streaming video of the weather channel to all workstations. We work construction.)



Private Sub CommandButton1_Click()

Shell "wmplayer.exe http://computer-name:8080/", vbMaximizedFocus

End Sub



Here's a command to launch a button that will open an FTP site within the actual Windows Explorer environment, so you can use drag/drop. VERY NICE if you're trying to tell a moron a simple way to connect to your FTP server:



Private Sub CommandButton1_Click()

Shell "Explorer ftp://ftpsitehere.com/", vbMaximizedFocus

End Sub



So, explore with that little "shell" command, and enjoy. Sorry for being a Richard Head earlier. But, I didn't give myself that name for no reason. I'm an angry nerd. I sit here at work all day, and read other people's problems.





This is as easy as it gets.



I'm laughing my *** off at the people who replied before I did. Wow, the madness they bring upon themselves.
doug
2008-12-04 06:48:20 UTC
if you're trying to communicate between two programs, consider pipes



http://www.vb-helper.com/howto_shell_get_hwnd.html



or DDE maybe, although I think this method is considered dated



http://support.microsoft.com/kb/213626



If you just want to call a program with vb, use windows Shell commands, you can probably find the documentation you need in the MSDN Library



http://msdn.microsoft.com/en-us/library/0xca6kdd.aspx



one other thing, if you are wanting to include Excel or word or internet explorer functionality in your app, Visual Studio allows you to include Active X/COM objects that encapsulates the functionality of those things, I am fairly certain. I know for a fact they do so for internet explorer. You can browse these available objects in Visual Studio.



edit:



lol @ Richard Head.



I too sit here all day and read about other people's problems.



I could do work, but work is hard. You will notice that I also mentioned Shell commands, kind sir. But the question of the OP was vague so I babbled on about other various things as well. Good day.
Some Guy
2008-12-04 06:46:28 UTC
Use late binding, so that you don't have to register OCX files or DLLs...



Simple example to open Excel:



Dim xcl, wBook, wSheet, wRange

set xcl = New Excel Application

set wBook = xcl. workbooks. add ' Remove spaces

set wSheet = wBook. Sheets ("Sheet1")

set wRange = wSheet. Range ("A1")



wRange. offset (0,0). value = "Test"



wBook. SaveAs "C:\excelsheet.xls"

wBook. Close

set wBook = nothing

xcl. Quit

set xcl = nothing



If you're certain that the Office application is always installed on the PC you're using your app on, you can use "early binding", by referencing the Office Application files in your source references, and using named references:



Dim xcl as Excel.Application

Dim wBook as Excel.Workbook

Dim wSheet as Excel.Worksheet

Dim wRange as Excel.Range



(That's using VB6 code, by the way...)



Check: http://msdn.microsoft.com/en-us/library/0tcf61s1.aspx to get you started
Ariel
2008-12-04 07:42:16 UTC
'' to open or execute any file based upon its extension

'' put this on top page (general declarations) of your form



Private 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





''-- call this on a command button

Shell "C:\Program Files\Microsoft Office\Office\Winword.exe", vbMaximizedFocus


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...