running word, excel, and acrobat from vb program
Author |
Message |
Allan Ker #1 / 5
|
 running word, excel, and acrobat from vb program
Hi, When I open a .doc or .xls file using the code below, it works, but when I try to open an acrobat or .jpg file, it fails. Any suggestions? Thanks, Allan If InStr(1, strFile, ".xls", vbTextCompare) > 0 Then Set objDoc = GetObject(strFile) objDoc.Application.Visible = True objDoc.Parent.Windows(1).Visible = True ElseIf InStr(1, strFile, ".doc", vbTextCompare) > 0 Then Set objDoc = GetObject(strFile) objDoc.Application.Visible = True ElseIf InStr(1, strFile, ".pdf", vbTextCompare) > 0 Then Set objDoc = GetObject(strFile) objDoc.Application.Visible = True ElseIf InStr(1, strFile, ".jpg", vbTextCompare) > 0 Then Set objDoc = GetObject(strFile) objDoc.Application.Visible = True Else Debug.Print "bad file type selected in docs" End If *** Sent via Developersdex http://www.*-*-*.com/ *** Don't just participate in USENET...get rewarded for it!
|
Wed, 21 Sep 2005 21:11:07 GMT |
|
 |
Tom Spin #2 / 5
|
 running word, excel, and acrobat from vb program
Hi Allan, Perhaps PDF and JPG don't have instantiable objects, how about trying this code: '=== Dim fiFile As New System.IO.FileInfo(strFile) Dim piProcess As New ProcessStartInfo() Select Case fiFile.Extension.ToLower Case ".xls", ".doc", ".pdf", ".jpg" piProcess.FileName = fiFile.FullName piProcess.UseShellExecute = True Process.Start(piProcess) End Select '=== Alternatively, you can s{*filter*}the select case statement and do the following: '=== Dim piProcess As New ProcessStartInfo() piProcess.FileName = strFile piProcess.UseShellExecute = True Process.Start(piProcess) '=== -- ============================================== Happy to Help, Tom Spink
http://www.*-*-*.com/ > .NET code (soon) One Day,
Quote: > Hi, > When I open a .doc or .xls file using the code below, it works, but when > I try to open an acrobat or .jpg file, it fails. Any suggestions? > Thanks, Allan > If InStr(1, strFile, ".xls", vbTextCompare) > 0 Then > Set objDoc = GetObject(strFile) > objDoc.Application.Visible = True > objDoc.Parent.Windows(1).Visible = True > ElseIf InStr(1, strFile, ".doc", vbTextCompare) > 0 Then > Set objDoc = GetObject(strFile) > objDoc.Application.Visible = True > ElseIf InStr(1, strFile, ".pdf", vbTextCompare) > 0 Then > Set objDoc = GetObject(strFile) > objDoc.Application.Visible = True > ElseIf InStr(1, strFile, ".jpg", vbTextCompare) > 0 Then > Set objDoc = GetObject(strFile) > objDoc.Application.Visible = True > Else > Debug.Print "bad file type selected in docs" > End If > *** Sent via Developersdex http://www.*-*-*.com/ *** > Don't just participate in USENET...get rewarded for it!
|
Wed, 21 Sep 2005 21:29:20 GMT |
|
 |
Allan Ker #3 / 5
|
 running word, excel, and acrobat from vb program
Thanks. That looks like a better way to do it. But I think it's using dotnet code, and I'm still using VB6 and ProcessStartInfo is not recognized. I don't suppose you know how to do this in VB6? Thanks, Allan *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
|
Thu, 22 Sep 2005 20:41:22 GMT |
|
 |
Tom Spin #4 / 5
|
 running word, excel, and acrobat from vb program
Hi Allan, this is a VB.NET newsgroup, which is why I gave you that code. To do it in VB6, you can use the shell function: Shell strFile, vbNormalFocus Visit the microsoft.public.vb.* newsgroups -- ============================================== Happy to Help, Tom Spink
http://dotnetx.betasafe.com > .NET code (soon) One Day,
Quote: > Thanks. That looks like a better way to do it. But I think it's using > dotnet code, and I'm still using VB6 and ProcessStartInfo is not > recognized. I don't suppose you know how to do this in VB6? > Thanks, Allan > *** Sent via Developersdex http://www.developersdex.com *** > Don't just participate in USENET...get rewarded for it!
|
Thu, 22 Sep 2005 22:00:24 GMT |
|
 |
Herfried K. Wagne #5 / 5
|
 running word, excel, and acrobat from vb program
Hello Tom,
Quote: > Hi Allan, this is a VB.NET newsgroup, which is why > I gave you that code. To do it in VB6, you can use > the shell function: > Shell strFile, vbNormalFocus > Visit the microsoft.public.vb.* newsgroups
Shell doesn't work with non-executables. Use ShellExecute instead: \\\ 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 Private Const SW_NORMAL As Long = 1& Private Sub Form_Load() Call ShellExecute( _ Me.hwnd, _ "open", _ "C:\Ordner\bla.doc", _ vbNullString, _ vbNullString, _ SW_NORMAL _ ) End Sub /// Regards, Herfried K. Wagner
|
Thu, 22 Sep 2005 23:02:35 GMT |
|
|
|