ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macros associated with pictures (https://www.excelbanter.com/excel-discussion-misc-queries/24065-macros-associated-pictures.html)

Eric

Macros associated with pictures
 
I am working with Excel 2000.

I have a worksheet that has several pictures on it. Each picture has an
associated macro. The macros are in an extenal workbook. Currently each
picture, when it tries to access the macro, it cannot find the file, because
the file containing the macros has been moved. I have a number of files
that are setup this way and need a macro that will go in and automatically
remove the folder/path refference from the file/macro reference.

Example:
Currently referenced macro:
F:\Dir1\SubDir2\SubSubDir3\OperatorMacros.xls!Pict ure6_Click

I want it to read:
OperatorMacros.xls!Picture6_Click

I have 6 pictures on the worksheet and each picture has the same problem.

Also, can I set something such that it doesn't ever try to reference a path
for the file. I already have the workbook set up to make sure the file that
has the macros in it is loaded.

Please help, and thank you in advance.

Eric Pearce



Bob Phillips

Put your macros in an add-in, and install the ad-in.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Eric" wrote in message
...
I am working with Excel 2000.

I have a worksheet that has several pictures on it. Each picture has an
associated macro. The macros are in an extenal workbook. Currently each
picture, when it tries to access the macro, it cannot find the file,

because
the file containing the macros has been moved. I have a number of files
that are setup this way and need a macro that will go in and automatically
remove the folder/path refference from the file/macro reference.

Example:
Currently referenced macro:
F:\Dir1\SubDir2\SubSubDir3\OperatorMacros.xls!Pict ure6_Click

I want it to read:
OperatorMacros.xls!Picture6_Click

I have 6 pictures on the worksheet and each picture has the same problem.

Also, can I set something such that it doesn't ever try to reference a

path
for the file. I already have the workbook set up to make sure the file

that
has the macros in it is loaded.

Please help, and thank you in advance.

Eric Pearce





Eric

Though I cannot remember the specifics, I tried an Add-in and it would not
work the way I needed it to. However, with a little effort I was able to
identify the fix.

Dim theShapes As Shapes
Set theShapes = Workbooks(ActiveBook).Worksheets(1).Shapes
myFile = "OperatorMacros.xls"
For i = 1 To theShapes.Count
Select Case i
Case Is = 2
theShapes.Item(i).OnAction = myFile & "!Picture6_Click"
Case Is = 3
theShapes.Item(i).OnAction = myFile & "!Picture7_Click"
Case Is = 4
theShapes.Item(i).OnAction = myFile & "!Picture9_Click"
Case Is = 5
theShapes.Item(i).OnAction = myFile & "!Picture11_Click"
Case Is = 6
theShapes.Item(i).OnAction = myFile & "!Picture10_Click"
Case Is = 7
theShapes.Item(i).OnAction = myFile & "!Picture8_Click"
End Select
Next i

Allowed me to loop through each picture and reset the macro reference.

I do appreciate the suggestion, and maybe would have found some help with
the whole add-in issue had I asked, but thank you for your time anyway.

Eric Pearce

"Bob Phillips" wrote in message
...
Put your macros in an add-in, and install the ad-in.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Eric" wrote in message
...
I am working with Excel 2000.

I have a worksheet that has several pictures on it. Each picture has

an
associated macro. The macros are in an extenal workbook. Currently

each
picture, when it tries to access the macro, it cannot find the file,

because
the file containing the macros has been moved. I have a number of files
that are setup this way and need a macro that will go in and

automatically
remove the folder/path refference from the file/macro reference.

Example:
Currently referenced macro:
F:\Dir1\SubDir2\SubSubDir3\OperatorMacros.xls!Pict ure6_Click

I want it to read:
OperatorMacros.xls!Picture6_Click

I have 6 pictures on the worksheet and each picture has the same

problem.

Also, can I set something such that it doesn't ever try to reference a

path
for the file. I already have the workbook set up to make sure the file

that
has the macros in it is loaded.

Please help, and thank you in advance.

Eric Pearce








All times are GMT +1. The time now is 06:57 AM.

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