Trying To Modify VBA To Repeat This On All Sheets In The Workbook except a few

Jingles3X

New Member
Joined
Oct 20, 2021
Messages
34
Office Version
  1. 2013
Platform
  1. Windows
Hi!
I have the code below, which is working to let me insert a picture in the specified location, but I am trying to have it repeat the process
on all sheets, excluding just a few. I have tried multiple ways to do it, with no success.
Can anyone make a suggestion on how to do this?

VBA Code:
Sub GetPic()
Dim fNameAndPath As Variant
Dim img As Picture         
fNameAndPath = Application.GetOpenFilename(Title:="Select Picture To Be Imported")
If fNameAndPath = False Then Exit Sub
    Set img = ActiveSheet.Pictures.Insert(fNameAndPath)
    With img
       'Resize Picture to fit in the range....
       .Left = ActiveSheet.Range("AC1").Left
       .Top = ActiveSheet.Range("AC1").Top
       .Width = ActiveSheet.Range("AC7:AI7").Width
       .Height = ActiveSheet.Range("AC1:AC7").Height
       .Placement = 1
       .PrintObject = True
       End With

End Sub
 
My mistake, that line should be
VBA Code:
.DrawingObject.PrintObject = True
I seem to be having a different issue now....
The RED line below is giving me a "Type 13", Mismatch error.
I have tried to figure out what's going on, but not successfully.


VBA Code:
Sub Print_Sheets()
Dim I As Long, c As Long
Dim SheetArray() As String

    With ActiveSheet.ListBoxSh

        For I = 0 To .ListCount - 1
            If .Selected(I) Then
                ReDim Preserve SheetArray(c)
                SheetArray(c) = .List(I)
                c = c + 1
            End If
        Next I

        [COLOR=rgb(226, 80, 65)]Sheets(SheetArray()).PrintPreview[/COLOR]
        
        'If you'd like to print out
        'Sheets(SheetArray()).PrintOut

    End With

End Sub
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
There are a few possible causes for that:
- one of the sheets doesn't exist due to a typo in its name;
- one of the sheets is hidden / very hidden;
- the SheetArray variable contains an Empty element.
 
Upvote 0

Forum statistics

Threads
1,214,403
Messages
6,119,309
Members
448,886
Latest member
GBCTeacher

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