?
Solved

How to open a PDF file in VB

Posted on 2003-03-13
7
Medium Priority
?
144 Views
Last Modified: 2010-04-07
Hello!

I would like to open a PDF file in VB 6.0. I currently use a WebBrowser control to show a PDF file, but it requires an extra form. Is there a way to open a PDF file in a web browser without using a WebBrowser control?

Thanks.
Peter
0
Comment
Question by:k0ndi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Expert Comment

by:makman
ID: 8134702
Hi k0ndi,
U can use AppActivate command (Application Activate command)
just go through the following code
same way use PDF file here.
In web browse in activate method you can give this command.
Private dblWordID As Double
'// runs word
Private Sub cmdRunWord_Click()
    dblWordID = Shell("notepad", vbNormalFocus)
End Sub
'// activates word at a later stage
Private Sub cmdActivateWord_Click()
    AppActivate dblWordID
End Sub
Regards,
Makman
0
 

Expert Comment

by:makman
ID: 8134706
Peter just go through the above code i have given you.
Regards,
Makman
0
 

Author Comment

by:k0ndi
ID: 8134801
Thanks Mahman. That only seems like one part of the solution, because I still need to open a document. Your code only opened an application, but I still need to open a document in the activated application.

Regards,
Peter
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:makman
ID: 8134837
Peter,
To open a specific file in vb u can use an openfile method availabe in api
Public Declare Function OpenFile Lib "kernel32" Alias "OpenFile" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
u can direcly use this method to open the file in any appilcation.
Regards,
Makman.
0
 

Expert Comment

by:makman
ID: 8134846
Peter,
if it is in web check out the document.navigateto(filename)
method in browsers.
regards,
Makman.
0
 
LVL 5

Accepted Solution

by:
Cimperiali earned 200 total points
ID: 8135888
If in your system something is related to that file and you want system to open it with appropriate program, use following code:
Option Explicit
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
Const SW_SHOWNORMAL = 1

Private Sub Command1_Click()
Call launchIt("c:\yourFile.pdf")
End Sub

Private Sub launchIt(strPathAndFile As String)
    ShellExecute Me.hwnd, vbNullString, strPathAndFile, vbNullString, "C:\", SW_SHOWNORMAL
End Sub
0
 

Author Comment

by:k0ndi
ID: 8138604
Thanks both makman and Cimperiali. The ShellExecute worked like a charm. I haven't tried to use the OpenFile, but I'm sure it would work.

Thanks again.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question