Add background from image on worksheet w/ VBA

Cease

Board Regular
Joined
Dec 28, 2010
Messages
112
Hi everyone,
I have a Workbook that I email to users, and from this workbook the users send emails to their team (these emails are one sheet from the workbook, that changes with data validation). I'm trying to find a way to have those sheets have a background, and feel that I am close.

I know how to apply a background from a file, and thought I could alter it, yet I'm having little success.

As it is now, I have the pictures stored on sheet named: "Picky"
and need to apply them to "Sheet1"
Here's the code that I have
Code:
Sub newback()
    Dim Pic As Excel.Picture
    Windows("Beast.xlsm").Activate
    Set Pic = Worksheets("Picky").Pictures("ForcePic")
    Windows("Selection of Beast.xlsm May-16-2011.xlsx").Activate
    Sheets("Sheet1").Select
     ActiveSheet.SetBackgroundPicture Filename:= Pic
End Sub
This returns an error saying Type Mismatch.
Makes sense since it's not from a File, I've just been able to find proper syntax for this operation.

Anyone have any idea how I can get this to work?

Thank you for your time!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Jafaar,
Thank you so much for the response, I'm looking through the code and will try it out.
This seems like a really good option to set up what I was looking for.

Thanks!
 
Upvote 0
Jafaar,
I apologize, I couldn't make it work with the example you gave me, largely due to my ignorance of VBA.

I found something else that converts a chart to a picture, and tailored it to show like this:
Code:
Sub Pickback()
Dim ForcePic As String
    ForcePic = Environ$("temp") & "\Beast1.jpg"
    ActiveWorkbook.Worksheets("Picky").ChartObjects("Picture 2").Chart.Export _
        Filename:=ForcePic, FilterName:="JPG"
    ActiveWindow.Sheets("The Force").Activate
    ActiveSheet.SetBackgroundPicture ForcePic
    Kill ForcePic
 
End Sub

My problem being that I'm not dealing with a chart, and I don't know the syntax to change this to work for a picture.
I tried a lot of changes but can't seem to get them right.

Any thoughts?

Thank you!!
 
Upvote 0
I got it!!
So I inserted a blank chart, filled the background with the picture and voila.
Oh that's awesome.

Thank you for your help!
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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