Excel-VBA Help

c_m

Well-known Member
Joined
May 29, 2008
Messages
836
Hello,

I have a excel file where I have a flowchart. I am trying to link each box in flowchart to a picture that happens to be in the same directory as the excel file.
All I want to do is when I click on the textbox, I want a particular bmp or jpeg to be inserted in the document.
I tried with macro recording and it worked. The concern is I am going to explain this flowchart to clients and all my data will be on flash drive.
So I have to get rid of the absolute path of the jpeg location and make it dependent on the directory or path where the excel file is located.
Any ideas how to do it?

Thanks
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
If your file is located in the same map, you can just use Open "filename"

For example, this will open Workbook1 if it is in the same map (else error)

Code:
Workbooks.Open "Workbook1"

You can adept this to insert pictures etc.
 
Upvote 0
This is not working.
I tried

ActiveSheet.Pictures.Insert("cs.bmp").Select

(cs is the bitmap image in the same folder as the excel file)

I get
Run-time error '1004':
Unable to get the Insert Property of the Pictures class

However it works fine if I specify the absolute path of the picture
 
Upvote 0
I'm not quite sure if this will work, it's something i just cam up with:

Can't you try to get the absolute, full path of the location, store this in a string and strip it to the last "\". You could then use
Code:
ActiveSheet.Pictures.Insert(path & "cs.bmp").Select
 
Upvote 0
Thats a very good comment. I was thinking about the same.
The code that you werent sure of worked perfect.
So if I could just store the address of the folder where all my stuff is resting in and store it in string, I should be good to go.
Thankyou very much
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top