473,796 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a .pdf file from a VB6 .exe

3 New Member
Total noobie here, so spoon feed and speak slowly (and with code bytes) please.

What I am trying to accomplish is a VB6 .exe menu program that will be set to autostart on a info CD. If you click on a button on the menu it will open a file from the CD. Easier said than done. The problem I ran into right off is Adobe Reader versions, directory differences, drive letter differences, etc...

So I need the .exe to work without having to call anything by specific drive letter (C:\Program Files\Adobe\Rea der 9.0\Reader\Acro Rd32.exe is a perfect example. what if its a different version, location, drive)

So far I seem to have the AcroRd32.exe problem solved (many thanks to bytes forum posters, all of you), but am still hung up on calling up the actual .pdf file without using drive letters.

This is what I have so far:

Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA" (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 Sub Command1_Click( )
ShellExecute 0&, "OPEN", "X:\Files\broch ure.pdf", "", "", 1
End Sub

This works well so far, but still relies on a drive letter.

The .exe file would be placed on X:\ following the above example, and the supporting files (brochure.pdf in this case) would be in a hidden subfolder X:\Files\

Any input is greatly appreciated.
Nov 19 '08 #1
2 10591
smartchap
236 New Member
Because .exe file will be in X:\ dir and .pdf file in X:\Files\ dir so try using this in your command (in place of X:\Files\xxx.pd f) :

ShellExecute 0&, "OPEN", App.path & "\Files\" & "xxx.pdf", "", "", 1

Hope it will solve your problem. Do acknowledge it.
Nov 19 '08 #2
Shayne82609
3 New Member
Because .exe file will be in X:\ dir and .pdf file in X:\Files\ dir so try using this in your command (in place of X:\Files\xxx.pd f) :

ShellExecute 0&, "OPEN", App.path & "\Files\" & "xxx.pdf", "", "", 1

Hope it will solve your problem. Do acknowledge it.

Thank you for the reply smartchap. That works perfectly. If there is anyone else interested in doing the entire code is below. Cut and Paste at will.

1. Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA (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

2. Private Sub Command1_Click( )
3. ShellExecute 0&, "OPEN", App.Path & "\Files\" & "brochure.p df", "", "", 1
4. End Sub
Nov 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2080
by: Eric Caron | last post by:
Hi Here's my problem, I create a windows service with Config.xml file. All setup for my service is in this file. I create a windows application to manage these settings (Config.XML File). This work good if the two applications are in the same folder and Config.XML is in the folder too but If not, my windows application setting don't work. In my windows form I have a Service controler components to manage my service (start, stop, ...)....
2
1617
by: Fraser Ross | last post by:
I want to prevent std::basic_ifstream from opening a file for reading when it is passed the file name with any wrong case of a letter. If that can't be done is there anything else that could be done before opening? The program is for Windows. Fraser.
9
2324
by: ben | last post by:
Hello, This really drives me nuts. Im opening an input file, and Im testing if it was open successfully. Thats it! I know that the file that Im trying to open DOES NOT exist but Im getting NO error message. No matter what name I enter I get 'file opened successfully" Any clues? Thanks!
1
4404
by: Alfons | last post by:
Hello, I have build a program that can do file transferring between a Windows XP computer and a DOS computer via a serial port. The Windows program I have build in C++ with Visual Studio 6.0. The DOS program I made in Turbo C++ 3.0. At this moment I am in a test phase of sending files and directories. The code I am using in DOS to open a file for writing looks like this (forgive me the typos, since I only have my source code at work...
28
3281
by: Madhur | last post by:
Hello what about this nice way to open a file in single line rather than using if and else. #include<stdio.h> void main() { FILE *nd; clrscr(); fopen("c:\\autoexec.bat","r")&&printf("success") || printf("error opeing
4
2175
by: Pieter | last post by:
Hi, From my VB.NET 2005 application I need to be able to open Files an Directory's with their default application: - A word-doc must open in word - A excell-document in Excel etc - in case it's a folder it must open the Folder No problem there, but when I want to open a file without extension, that hasn't offcourse a default application, I'm getting an error. I'd prefer to
5
1984
by: bimeldip | last post by:
Hi, I an tryin to create a html page where users can choose a file and open it however, i keep getting it wrong.So far this is wat i've worked on: (open.html) <html> <head> <title>Opening file</title> </head> <body> <form action="display.php" method="POST"> Please choose a file: <input name="saved" type="file" /><br />
0
1222
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I need to open a text file with .net remoting. This text file resides on another server. My server program running on the server has this method that opens the text file System.Diagnostics.Process.Start(filePath); My client program has a button which I click and it call the server program method that opens the file. When I click the button, the file opens on the server itself, is it possible that I can see that file...
2
1788
by: sam | last post by:
Sir, I just wanted to know how i will opened file (any exe or other type file )in c++ and run it. and how we will give path when we are opening it. please give me the code of this small program. thanks in advance
2
1902
by: PaulSW | last post by:
I have a macro that loops through and opens a number of files. In each file there is an event procedure upon opening that displays an informational msgbox (The only option is to click ok). I'm trying to have my code click okay so that I don't have to sit here and hit enter (literally hundreds of times) as each file opens. Application.diplay alerts = false does not work, and changing the msgbox event procedure is unfortunately not an option. ...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.