Working with Canvas Objest Instead of Picture Objects in VBA

nryan

Board Regular
Joined
Apr 3, 2015
Messages
61
Hello All!

This is my first thread. Forgive me if I violate the forum rules.

I'm working with a VBA macro that was written by an intern who is now gone. The VBA code uses If-Then-ElseIf statements to hide and show pictures on a worksheet. The following is the piece of the code that I am interested in:

HTML:
Instructions.Shapes.Range(Array("Zero_Dual", "Zero_Single", "RCS", "RCD", "Z0_Dual", "Z0_Single", "RSD", "TCMS", "TCSS", "TCSD", "TCMD", "FSMS", "FSSS", "FSMD", "FSSD" _
,"GSSGM", "GSSGS", "FTMS", "FTSS", "FTGDM", "FTMD", "FTDGS", "FTSD", "BSM", "BSS", "BDGM", "BMD", "BDGS", "BSD")).Visible = False

All the objects in "quotes" are names of pictures on the worksheet. I've taken these pictures, put them in Microsoft Word, put them into a drawing canvas, and added arrows and text to make them easier to understand by the user (hopefully). I copy/pasted them back into the worksheet to replace the old pictures and made sure all the names were the same. When pasting I kept the source formatting so instead of pictures objects they are now canvas objects in the worksheet. This is ideal because I want to be able to change the text inside the pictures in the future. The problem is when running the VBA macro I now get "Compile error: Method or data member not found." I think this is because the pictures are now canvas objects and Shapes.Range doesn't recognize them.

I have 2 options: 1) Remove all canvas objects and copy/paste them back in the worksheet as pictures or 2) change the VBA code.

I know how to do the first option. Do you guys know how I can do the second option? That is, what can I use to recognize/return canvas objects in the VBA code?

I Thank you in advance: Thank you,
Nick
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hello Nick and welcome to the Board

Please select a canvas object by clicking it, run the macro below and report back the result:

Code:
Sub TestObject()


MsgBox TypeName(Selection)


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,269
Messages
6,123,976
Members
449,138
Latest member
abdahsankhan

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