ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open files from a dynamic path.. (https://www.excelbanter.com/excel-programming/378195-open-files-dynamic-path.html)

Arjan

Open files from a dynamic path..
 
Hi al..

I have a problem.. I placed the question here last week aswell, unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open certain
adobe PDF files. Furthermore, this project is to be burned on a CD so it can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****

NickHK

Open files from a dynamic path..
 
Arjan,
Depends where the PDFs are relative to the Excel WB. You already have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,

unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open certain
adobe PDF files. Furthermore, this project is to be burned on a CD so it

can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****




Arjan

Open files from a dynamic path..
 
Nick,

Thanks for your reply.. The files are in the same path as the workbook.
However, what I don't know is the how to open the file(s)..

what code do I have to use?

Arjan




--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
Depends where the PDFs are relative to the Excel WB. You already have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,

unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open certain
adobe PDF files. Furthermore, this project is to be burned on a CD so it

can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****





NickHK

Open files from a dynamic path..
 
If you just want to open them in the user's defualt app for pdf files :

Public 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

ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1

NickHK

"Arjan" wrote in message
...
Nick,

Thanks for your reply.. The files are in the same path as the workbook.
However, what I don't know is the how to open the file(s)..

what code do I have to use?

Arjan




--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
Depends where the PDFs are relative to the Excel WB. You already have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,

unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open

certain
adobe PDF files. Furthermore, this project is to be burned on a CD so

it
can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and

open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****







Satish

Open files from a dynamic path..
 
Are you using a fileopen dialog box for the user to select the file?

If not, you could try using it...it will return you the entire path of
the selected file/folder

check FileDialog Property in help.

HTH
-Satish

Arjan wrote:
Hi al..

I have a problem.. I placed the question here last week aswell, unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open certain
adobe PDF files. Furthermore, this project is to be burned on a CD so it can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****



Arjan

Open files from a dynamic path..
 
Nick,

Sorry to bother you again..
I tried to insert the code, unfortunalty there's a compile-error which
states that
it expects a rulenumber or a name or a instruction or a instruction-end..

I do have to put the code in the command button sub? Or do I make a mistake?



--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

If you just want to open them in the user's defualt app for pdf files :

Public 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

ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1

NickHK

"Arjan" wrote in message
...
Nick,

Thanks for your reply.. The files are in the same path as the workbook.
However, what I don't know is the how to open the file(s)..

what code do I have to use?

Arjan




--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
Depends where the PDFs are relative to the Excel WB. You already have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,
unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open

certain
adobe PDF files. Furthermore, this project is to be burned on a CD so

it
can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and

open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****







Arjan

Open files from a dynamic path..
 
Nick, sorry to bother you again...

When i put this code in the commandbutton sub it returns a complie error.
It suspects a rulenumber, a name an instruction or an instruction end.

I do have tp put this code in the commandbutton sub? or do i make a mistake?

thanks again for your help!

Arjan


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

If you just want to open them in the user's defualt app for pdf files :

Public 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

ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1

NickHK

"Arjan" wrote in message
...
Nick,

Thanks for your reply.. The files are in the same path as the workbook.
However, what I don't know is the how to open the file(s)..

what code do I have to use?

Arjan




--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
Depends where the PDFs are relative to the Excel WB. You already have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,
unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open

certain
adobe PDF files. Furthermore, this project is to be burned on a CD so

it
can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation and

open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****







NickHK

Open files from a dynamic path..
 
Arjan,
OK, this a bit more correct :

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 Sub CommandButton1_Click()
ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1
End Sub

NickHK

"Arjan" wrote in message
...
Nick,

Sorry to bother you again..
I tried to insert the code, unfortunalty there's a compile-error which
states that
it expects a rulenumber or a name or a instruction or a instruction-end..

I do have to put the code in the command button sub? Or do I make a

mistake?



--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

If you just want to open them in the user's defualt app for pdf files :

Public 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

ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1

NickHK

"Arjan" wrote in message
...
Nick,

Thanks for your reply.. The files are in the same path as the

workbook.
However, what I don't know is the how to open the file(s)..

what code do I have to use?

Arjan




--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
Depends where the PDFs are relative to the Excel WB. You already

have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting

that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,
unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open

certain
adobe PDF files. Furthermore, this project is to be burned on a CD

so
it
can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent

drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation

and
open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****









Arjan

Open files from a dynamic path..
 
Nick,

thnx!! works great.. you've been a great help!!
--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
OK, this a bit more correct :

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 Sub CommandButton1_Click()
ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1
End Sub

NickHK

"Arjan" wrote in message
...
Nick,

Sorry to bother you again..
I tried to insert the code, unfortunalty there's a compile-error which
states that
it expects a rulenumber or a name or a instruction or a instruction-end..

I do have to put the code in the command button sub? Or do I make a

mistake?



--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

If you just want to open them in the user's defualt app for pdf files :

Public 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

ShellExecute 0, "open", Thisworkbook.path & "\YourPDF.pdf", "", "", 1

NickHK

"Arjan" wrote in message
...
Nick,

Thanks for your reply.. The files are in the same path as the

workbook.
However, what I don't know is the how to open the file(s)..

what code do I have to use?

Arjan




--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****


"NickHK" wrote:

Arjan,
Depends where the PDFs are relative to the Excel WB. You already

have
ThisWorkbook.Path, so if they in a sub folder of that :
ThisWorkbook.Path & "\PDF_Folder\PDF1.pdf"

If you maybe on Mac then you would need to do bit work at detecting

that
first.

NickHK

"Arjan" wrote in message
...
Hi al..

I have a problem.. I placed the question here last week aswell,
unfortunatly
it did not solve my problem..

Scope:
I have a userform where I would like to add some buttons wich open
certain
adobe PDF files. Furthermore, this project is to be burned on a CD

so
it
can
be distributed.
My problem are the drive letters.. (diffrent systems, diffrent

drive
letters..)

this is the code i'm using..
_______________

Private Sub CommandButton19_Click()
'open pdf file
Dim filelocation As String
filelocation = ThisWorkbook.Path
_________________

I'm missing the last part where I call the variable filelocation

and
open
the pdf file..
Who can help me out?


--
Arjan Bregman

*****
the knowledge is always there, maybe hidden, but it is there..
*****











All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com