Insert Image - Center & Zoom
I have a worksheet (Covers) that is going to be the front and back covers for a binder.
The title/text portion is automatically filled from cells elsewhere in the workbook.
I have a button to bring up a userform that allows one to select the images (3 .jpg images) you wish to use on the cover pages.
I have code that successfully brings up the userform, and allows image selection and preview within the userform.
Now I want to insert these selected images into the worksheet, centered on specified cells and sized (zoom) to a maximum width/height (whichever is reached first).
Can a blank Picture be inserted with its size specified/fixed, then use code (Image1 = LoadPicture?) to change what is displayed?
Or do I have to calculate the size, center it on the page, and insert the image each time?
The code (in part) for the UserForm looks like:
Private Sub SelFcvrImg_Click()
Dim FCpicName As Variant
ChDir ("S:DanBuilder Logos-Photos")
FCpicName = Application. GetOpenFilename(Title:="Select an Image!", _
If FCpicName <> False Then InsertImgForm.FCoverImgPrvw.Picture = LoadPicture(FCpicName)
The UserForm has an Image (preview) with PictureSizeMode set to zoom.
I'm really after the same thing embedded in the sheet...
View Complete Thread with Replies
Related Forum Messages:
Center On Zoom In A Frame
I am developing a form for emergency dispatching. One of the features of this dispatch sheet is that there are several maps in it that open on a seperate form. The map form has 4 maps that are picture files in an image. these images are in a frame. The different images are selected using option buttons. Given the background above, my problem is this. I have code that zooms in 50% each time the Click event for the image is fired. wht i am trying to do is make the zoomed view center where i clicked. this is the code that i have so far but it doesn't work all that spectacular, the closer I zoom in the further out of center the place i clicked gets untill it is out of view.
Private Sub Layout_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
CurrentX = X
CurrentY = Y
Private Sub PlantLayout_Click()
If Frame1.Zoom < 400 Then Frame1.Zoom = Frame1.Zoom + 50
frmmap.Frame1.ScrollLeft = CurrentX - (Frame1.Width / 2)
frmmap.Frame1.ScrollTop = CurrentY - (Frame1.Height / 2)
Center Inserted Image Within Range
I am having some troubles inserting an image than centering it within the cell.
When I do this:
Set rng = Target.Cells
.Height = rng.Height
.Width = rng.Width
.Left = rng.Left
.Top = rng.Top
The picture fits within the borders of the cell, but when I do this:
Set rng = Target.Cells
.Height = rng.Height /2
.Width = rng.Width /2
.Left = rng.Left /2
.Top = rng.Top /2
The picture is the right size but not within the cell.
I have a multi-row ,multi-column spreadsheet which lists furniture items, and with some plain Excel formulas allows me to create a proper list.
I'm using Excel as a database, in Sheet1 I have all the data, and Sheet2 is actually where I select the data and set the list of the chosen items.
Now, I have the images for all the items listed in Sheet1 in the same folder of the xlsm file, and I want to insert the proper image in a given cell in the given row.
Looking for something which may do the trick I did find this code in your site and it actually works for me!
Now, what I need is to provide the PictureFileName and TargetCell via parameters already present in the spreadsheet.
Say I want to retrieve the image shelves.jpg which is in the folder DATABASEimgs in your code mentioned above I manually set the string for PictureFileName like this
Insert Image Macro
I want to be able to click a button on my Excel Spreadsheet that will take me to my JPeg Photo location and allow me to add a JPeg Photo.
I have the below code but i does not recognise the JPeg File, so it work upto actually being able to select an image.
Insert Image Into Cell From Internet
I want a function that takes a URL string and then inserts a picture into the cell and fits it into the size of the cell (which I made square). The images are small but over 50 000 so it would be impractical to download them all; thus I want the spreadsheet to insert a specific one, based on my formula.
Tried a macro I found but it only gave the the '1004 Picture class' error.
So the function must be simple to use, maybe: ....
Insert Image Using Cell For Part File Name
Split from Open Image Using A String & Cell For File Name. what it looks like, but maybe I am not using the FollowHyperlink correctly?
Application. ScreenUpdating = False
'Picture = ActiveSheet. Range("W4").Value This works manually with the path in "W4"
'Now I tried to use the FollowHyperlink next
Application.FollowHyperlink "C:Documents and Settingsjim hutchMy DocumentsNarrative1My Appraisals2009-" & Sheets("Base").Range("B2") & "floodmap.jpg"
Exists = Dir(Picture, vbNormal).....................
Display Image Based On Image Name In Cell
Is there a way to have image box display an image with a name matching data from a cell? example: if I type "hello" in cell a1, Image box will load image named "hello". And display new images by changing the name in cell a1. Note: the images will be located in a permanent folder.
Add Image To Worksheet Image Control
I am trying to display an image ("image") on an image control ("Image1") placed in a worksheet ("Sheet1"). The problem is that I want this action to take place when I press a button in a user form. I am trying to use the following code, but it seems that VBA does not recognize the image control ("Image1") in the worksheet.
Private Sub cmdDisplayImage_Click()
Dim image As Variant
image = ThisWorkbook.Path & "sun.jpg"
Image1.Picture = LoadPicture(image)
UNMERGE And CENTER ACROSS
"Get rid of merged cells!"
You can read it often on this Board.
I will not open any debate on the subject, but just want to provide a solution to get rid of them automatically. Anybody who likes can refer to this thread.
This code is changing layout.
1. Could take a while when you have sheets with large used range or a lot of merged cells. You can follow the status and can interrupt it if you want.
2. Save before executing. I'm quite sure it works good, but the result might be something else then you had in mind, especially when you are quite new to this.
'Erik Van Geit
'merged cells will be unmerged
'contents will be centered across merged area
Dim LR As Long 'Last Row
Dim LC As Integer 'Last Column
Dim i As Long
Dim j As Long
Center Message In Msgbox
How can I get the message to display in the center of the display box?
If i < 3 Then If MsgBox(Tries - i & " Tries Remaining." & vbLf & vbLf & " Try Again?", vbYesNo) = vbNo Then Exit For
As you can see the "try again?" & the text "Tries Remaining"works fine by entering spaces, but the number that is suppose to display with "Tries Remaining" does NOT center. How can I get the number to display in the center along with the text?
This is the complete code.
Private Sub Workbook_Open()
Dim i As Integer, Tries As Integer
Dim PassTry As String
Const Pass As String = "Password"
Dim storedPath As String
On Error Resume Next
storedPath = ThisWorkbook.CustomDocumentProperties("PathCertString").Value
On Error GoTo 0..................
Formatting Center Header
I'm trying to find some code that will format the center header to Arial Bold, size 14.
Currently I have the center header populated with the cell value E9 using -
ActiveSheet.PageSetup.CenterHeader = Range("E9").Value
I've been digging around on the internet, but can't figure out how to format the text automatically.
Macro To Center The Text
I have a macro that output a month based upon a date that has been entered in a row on my spreadsheet. I want the macro to center the text but im not sure of the syntax, the macro code is below:
Im using Excel 2007
How do i change the default zoom that excel views documents? Whatever view the last person saved the file as it opens in that zoom. I want it to open 75% zoom no matter what anyone saved the files as.
Custom Zoom Set At 90
If I send a workbook out with the zoom set at 90...will the zoom be at 90 when others open it.? Also, is there a worksheet event that I could insert to force a specific worksheet to always open with the zoom at 90??
Align Text Center In A Cell Using VBA
I have the following code,
i would like to select columns A:W and center the text
Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sh.Range("A1") = "W/O"
Sh.Range("B1") = "CUSTOMER"
Sh.Range("C1") = "DETAILS"
Sh.Range("D1") = "CUST PART NO"
Sh.Range("E1") = "STATUS"
Sh.Range("F1") = "NOTES"
Sh.Range("G1") = "DEPARTMENT"
Sh.Range("H1") = "DATE"
Sh.Range("I1") = "CUST ORDER NO"
Sh.Range("J1") = "DEL NO"
Sh.Range("K1") = "QTY"
Sh.Range("L1") = "SALE PRICE"
Sh.Range("M1") = "CARRIAGE OUT"
Sh.Range("N1") = "TOTAL SALES"
Sh.Range("O1") = "INT CODE"
Sh.Range("P1") = "SUPPLIER"
Sh.Range("Q1") = "COST PRICE"
Sh.Range("R1") = "CARRIAGE IN"
Sh.Range("S1") = "TOTAL HRS"
Sh.Range("T1") = "LABOUR COST".......................
Cells To Align To Center/left/right
Here's a weird one: I can't get some of my cells to align to center/left/right. Both the buttons on the toolbar and Format->Cells->Alignment won't work. The kicker is that other cells on the same sheet will center/left/right just fine. Is there some kind of formatting protection I inadvertently set?
fyi, Excel 2003 on XP Pro, all fully updated.
Center As Default When Open Worksheet
i am tring to make any workbook i open when i writ in it, i want what i wrot to be in centerd
Private Sub Workbook_Open()
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
With sh. Cells
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End Sub ............
Center UserForm On Screen On Show
I'm having trouble centering my UserForms on the screen. I have tried all the options on the StartUpPosition in the Properties windows and the closest I can get is vertically centered but on the far left. The annoying thing is that it was working (both vertically and horizontally centered) but when I changed the defaults of the option buttons they moved to the position I described. I have two monitors (but excel is maximised on one monitor only) could this have something to do with my problem? If so why did it work before?
Copy Zoom To New Sheet
I have a sub that copies worksheet to a different blank sheet in a different work book. Is there a way for me to set the zoom value on the 2nd sheet (the one being copied to) the same as the 1st sheet?
Code To Open WS In 70% Zoom
I could need a code (WS code I assume) that open the sheet in 70% zoom every time I open that sheet. For now I get in 75% every time I open it. I guess that WS code will bypass that default setting, or bug, or what ever resets it 75%.
Zoom Worksheets To Fit Used Range
to apply a zoom to Fit Selection on all worksheets upon file opening? I've read many posts on this and understand how to apply this via worksheet activation, but haven't discovered how to make this to happen to all worksheets when the file is opened.
Zooming the selection needs to happen in the workbook module due to additional sheets being added at random and because it will facilitate the flow of the meeting so that we don't have to wait for the user to select and zoom.
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
LCol = Cells. Find("*", Range("A1"), xlFormulas, , xlByColumns, xlPrevious).Column
Range(Cells(1, 1), Cells(1, LCol)).EntireColumn.Select
' Need code help here to apply to all worksheets
ActiveWindow.Zoom = True ' this works for the worksheet activation event only
Adjust Zoom With Scroll Bar
I've used various "zoom" searches and can't find what I need. My users have different amounts of toolbars so the amount of screen space changes. I need to zoom so 4 graphs show. Am looking to enable the user with a scroll bar where the user could click / slide the control to change the zoom size on the screen so they can see the 4 graphs at their preferred "zoom".
I would prefer a control on the sheet and link it to a macro (or line of code if that's the proper phrase) and let the user decide (some people will want bigger zoom due to eyesight etc).
Private Sub ScrollBarZoom_Change()
ScrollBarZoom.Value = ActiveWindow.zoom.Value
But I get Runtime error '424': Object required. Auto Merged Post Until 24 Hrs Passes;Nevermind. I found it. Answer was:
Private Sub ScrollBarZoom_Change()
ActiveWindow.zoom = ScrollBarZoom.Value
Cells Not Responding To Left, Right, Center Arrangment
I think I did something but I don't know What. I select a cell that has a 20 font Size I enter a number it show at the 20 Font. Now when I go some ware else in the work unselecting that cell the number went to font 10 and droped to the left bottom of the cell. When I select the cell again and select the the left middle and right to move the number it does not responed. It happens everyware in the worksheet.
Calculating A Call Center's Average Workload
I have a rather complex worksheet, but it needs lots of manual intervention, it calculates the number of staff needed at any given hour for a call center based on the calls offered for an hour, the calls for a day are copied into the calandar and the last 7 "Mondays" "Tuesdays" etc: calls are averaged to give me a call trend, what I need is a way of automaticly adding this data.
I have created dropdown boxes with all the dates, if I choose a date, I want to be able to fill the last 7 "Mondays data"
(Userform) Textbox, Center Text Vertically?
We can center horizontally with TextAlign (Left, right or center). Can we center text in a textbox on a userform vertically? I am working with multiple fonts, when a user selects a font I attempt to format a textbox as a display to show what is being created (Best WYSIWYG as I can). I have this particular font that is just ugly but is required. My textbox is set for a 12 point font but the displayed characters partially appear below the lower portion of the textbox. Think of cutting off about 1/3 of the bottom of all text in the textbox.
In my textbox it seems like the text could be moved up (some type of top margin?). All other fonts appear to display in the textbox vertically central, so I believe its the particular font selected causing the as displayed anomaly.
How To Size App. Window To Fit Cells? (not Zoom)
This "smells" like a simple question, but I've had no luck finding a way to [programmatically] adjust the App.Window to fit around some cells.
I've found "Application.Goto", also the Application.Width/Height setting. The App.Width setting is pixel based, so if there's an easy way to know a cell's pixel-location, that'll work too!
Dropdown Text Very Small At 55% Zoom
I have a form that has been set up at 55% for best view. The only problem I have is that all the dropdown boxes (List) that i have the text is extremly small. Is there anyway of changing the size of this text? just the size of the text in the dropdown not in the cell after the selection is made.
Scroll & Zoom Sheets Simultaneously
I have a workbook of 6 Sheets, what i want is that if i scrolled or zoomed one of the sheets i want all other sheets to be scrolled and zoomed accordingly identically.
to explain more: say I'm on "sheet1" and I scrolled down so i'm seeing range(K225:X250), now if i switched to any of the other sheets i want them all scrolled to the same range. so whatever sheets i choose i want to see range(K225:X250) in the same viewing properties "zooming".
Page Setup And Zoom Property
I was curious if in VBA is there a way to switch in the page setup from Fit to X Page by X Page to the Scaling %.
I have set all my pages to fit 1 x 1 and would now like to know the scaling % (Zoom) of the sheets.
How To Write An API To Control The Zoom Of A Worksheet
I want to know how to make a spreadsheet automatically control the zoom of a worksheet depending on the size of the screen it is opened on. For example, if it is opened on a screen of a certain size then it will set the zoom to 80% so the worksheet will show only a certain section. I want my worksheets to look the same on even the larger screens and not show the unused rows and columns around the section I am wanting to highlight.
In a previous thread I was told I might need to write an API to help me with achieving this. First of all, what is an API? Secondly, how do I go about writing one?
Graphically Adjusting Zoom Using A Scroll Bar
I am created a very simple account plan for colleagues in my team which is proving to be very poular with the exception of one thing.
I created the plan which is around 30 sheets on my laptops highest resolution setting. 1400 x 1050. Only one other colleague has this res available so of course when the rest of the team open it, it looks huge.
I need help with this as I'm still very new to excel, although learning very fast!
My preference for finding a fix for this would be to insert a scroll bar on each sheet that, when scrolled, changes the zoom of the page between a range of 50% and 100%. This may not be the best way of doing it but I'm trying to make the sheets as simple to use as possible as some of my colleagues are only just compuetr literate, let alone excel competent!
Capture Print Zoom Value Before Printing
In a previous, expired thread, the following code was suggested as a way to capture the page-setup zoom value after setting PagesTall and PagesWide. It works fine when single-stepping in the VB Editor and when run directly by the user, via a button click or Tools=>Macros...=>Run, but fails when run under a Worksheet_Activate() event call.
Does anyone understand why that is and/or have a fix or workaround?
MsgBox "Zoom factor is " & ActiveSheet.PageSetup.Zoom
Magnifying Glass To Zoom The Entire Screen !
Here is a Magnifying Glass that you can use in Excel I am not sure about the usefulness of it in the normal day to day use of Excel but it's cool and was challenging to programme. The actual round Glass is actually a simple XL userorm whose standard styles were changed.
Here is a workbook example : http://www.savefile.com/files/1177730
Just point to the round Glass with the mouse and move it around the screen to zoom in. It worked on my machine quite smoothly.
Here is the code that goes in a userform :
Private Declare Function StretchBlt Lib "gdi32" _
(ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long.............
Zoom Level Affects Shapes Positioning
X = 1
Do Until ActiveCell.Offset(X, X).Value = 0
X = X + 1
variable = Round(-0.026 * (X * X * X) + 0.56 * (X * X) + 24.7 * X + 5, 0)
Set Box = ActiveSheet.Rectangles.Add(ActiveCell.Offset(0, 0).Left, ActiveCell.Offset(0, 0).Top, variable, variable)
.ShapeRange.Fill.Transparency = 0.3
.Font.Size = 18
.Font.Name = "Trebuchet MS"
.Text = ActiveCell.NoteText
Force Maximized Window & Zoom On Used Range
I have the following code working great, however, it only applies to the worksheet that opens when the .xls file first opens. I need it to also apply to all of the sheets in the workbook, in particular sheets titled TNT & Variables
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = True
Application.DisplayFormulaBar = mFormulaBar
Private Sub Workbook_Open()
Dim oCB As CommandBar
For Each oCB In Application.CommandBars
oCB.Enabled = False
mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False
Application.EnableEvents = True
Application.WindowState = xlMaximized
ActiveWindow.Zoom = True
ScrollArea: Zoom Percentage Prevents Scrolling
I have a workbook with 4 worksheets in it. The first 2 worksheets have a restricted user area of A1:Z48.
Private Sub Worksheet_Activate()
ScrollArea = "A1:Z48"
On the first one of these sheets the user cannot scroll around the sheet unless they change the zoom percentage to 85% or above. The second sheet, which is almost identical, and has the same scroll area does not suffer from this problem.
Zoom Or Expand Line Chart X-axis
I have an Excel chart as a separate worksheet. It has 10,000 data points. Is there a way to Zoom in on the X-axis only. I am looking to expand or zoom the X-axis to take a closer look at the individual data points. Since I have 10,000, I need a way to take a closer look at an area defined by the mouse pointer. Can this be done with VB code? I am not looking to expand or zoom the "Y" axis, this can be done with the scale values. Can this be done with a mouse drag or double click on the area of the chart I want to expand.