ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Linking a VBA button to Excel cell (https://www.excelbanter.com/excel-programming/374041-linking-vba-button-excel-cell.html)

beginner here[_2_]

Linking a VBA button to Excel cell
 
I have tried to locate my answer by looking at the questions and answers from
prior posters, but have been unable to locate what I am looking for.

I am looking for a way to combine two results as one, and then look at that
new result in a PDF file, that is named the same. I know how to combine two
results into a new cell, what I do not know how to do is the VBA coding that
needs to be attached so this button can look up the PDF file by the same
name.

Example:

In Excel in cell [B2] you select from a dropdown list say Oregon, and then
in another dropdown list in cell [F2] you select Salem. Then in cell, [G2]
B2 and F2 would be combined to look like this. [Oregon-Salem]

So now, I would click on a button that would go where I store my PDF files,
and find and open the file called Oregon-Salem.

Any help would be appreciated.

Steve


beginner here

Linking a VBA button to Excel cell
 
In my haste to get this question up, I didn't re-read what I wrote. I would
like help in writing this code, not for somebody to do it for me.

Sorry about that.

Steve

"beginner here" wrote:

I have tried to locate my answer by looking at the questions and answers from
prior posters, but have been unable to locate what I am looking for.

I am looking for a way to combine two results as one, and then look at that
new result in a PDF file, that is named the same. I know how to combine two
results into a new cell, what I do not know how to do is the VBA coding that
needs to be attached so this button can look up the PDF file by the same
name.

Example:

In Excel in cell [B2] you select from a dropdown list say Oregon, and then
in another dropdown list in cell [F2] you select Salem. Then in cell, [G2]
B2 and F2 would be combined to look like this. [Oregon-Salem]

So now, I would click on a button that would go where I store my PDF files,
and find and open the file called Oregon-Salem.

Any help would be appreciated.

Steve


Stopher

Linking a VBA button to Excel cell
 
Do all these joined file names live in the same folder?

If so you could do:

Shell ("[put file path here]"&[joined name here as a variable or cell
reference]&".pdf")

This should open your pdf file.

Stopher


beginner here

Linking a VBA button to Excel cell
 
Stopher I have a problem. What am I doing wrong in this code. It seems that
VBA is looking for another ")", but I don't see it in the line of code that
you gave me. BTW thanks so much for anwering my question.

He is the code as I have it now:

Shell ("C:\Program Files\Adobe"& Range("F4").Select& ".pdf")

"Stopher" wrote:

Do all these joined file names live in the same folder?

If so you could do:

Shell ("[put file path here]"&[joined name here as a variable or cell
reference]&".pdf")

This should open your pdf file.

Stopher



Stopher

Linking a VBA button to Excel cell
 
Shell ("C:\Program Files\Adobe"& Range("F4") & ".pdf")

No need to select the range


Stopher

Linking a VBA button to Excel cell
 
Another thing

Shell ("C:\Program Files\Adobe\"& Range("F4")& ".pdf")

Need that extra \ in there as well


beginner here

Linking a VBA button to Excel cell
 
Thanks for the additional help, but I'm stilling getting an error. This time
it is saying: Invalid procedure call or argument

So here is my present code with the changes:

Shell ("C:\Program Files\Adobe\" & Range("F4") & ".pdf")

Steve

Stopher

Linking a VBA button to Excel cell
 

beginner here wrote:
Thanks for the additional help, but I'm stilling getting an error. This time
it is saying: Invalid procedure call or argument

So here is my present code with the changes:

Shell ("C:\Program Files\Adobe\" & Range("F4") & ".pdf")

Steve


Dim newpath as String, sStr as String
newpath = "C:\Program Files\Adobe\"
sStr = ("cmd /c " & newpath & Range("F4") &".pdf"

Call Shell(sStr, vbNormalFocus)

Stole this out of a post by Tom and adopted it for your instance.


beginner here

Linking a VBA button to Excel cell
 
Thanks will test this out this morning

"Stopher" wrote:


beginner here wrote:
Thanks for the additional help, but I'm stilling getting an error. This time
it is saying: Invalid procedure call or argument

So here is my present code with the changes:

Shell ("C:\Program Files\Adobe\" & Range("F4") & ".pdf")

Steve


Dim newpath as String, sStr as String
newpath = "C:\Program Files\Adobe\"
sStr = ("cmd /c " & newpath & Range("F4") &".pdf"

Call Shell(sStr, vbNormalFocus)

Stole this out of a post by Tom and adopted it for your instance.




All times are GMT +1. The time now is 07:17 PM.

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