Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I'm tying to generate a report with pictures, but I cannot get the pictures into a single cell. I can get the pictures to "float" around my worksheet, but I need to put them into a cell. How can I do this?
You can add the image into a comment.
Right-click cell > Insert Comment > right-click on shaded (grey area) on outside of comment box > Format Comment > Colors and Lines > Fill > Color > Fill Effects > Picture > (Browse to picture) > Click OK
Image will appear on hover over.
Microsoft Office 365 (2019) introduced new things called comments and renamed the old comments as "notes". Therefore in the steps above do New Note instead of Insert Comment. All other steps remain the same and the functionality still exists.
There is also a $20 product for Windows - Excel Image Assistant...
There is some faster way (https://www.youtube.com/watch?v=TSjEMLBAYVc):
Insert image (Ctrl+V) to the excel.
Validate "Picture Tools -> Align -> Snap To Grid" is checked
Resize the image to fit the cell (or number of cells)
Right-click on the image and check "Size and Properties... -> Properties -> Move and size with cells"
just go to google docs and paste this as a formula, where URL is a link to your img
=image("URL", 1)
afterwards, from google docs options, download for excel and you'll have your image on the cell
EDIT
Per comments, you dont need to keep the image URL alive that long, just long enough for the excel to download it. Then it will stay embedded on the file.
Now we can add a picture to Excel directly and easely. Just follow these instructions:
Go to the Insert tab.
Click on the Pictures option (it’s in the illustrations group).
In the ‘Insert Picture’ dialog box, locate the pictures that you
want to insert into a cell in Excel.
Click on the Insert button.
Re-size the picture/image so that it can fit perfectly within the
cell.
Place the picture in the cell. A cool way to do this is to first
press the ALT key and then move the picture with the mouse. It will
snap and arrange itself with the border of the cell as soon it comes
close to it.
If you have multiple images, you can select and insert all the images at once (as shown in step 4).
You can also resize images by selecting it and dragging the edges. In the case of logos or product images, you may want to keep the aspect ratio of the image intact. To keep the aspect ratio intact, use the corners of an image to resize it.
When you place an image within a cell using the steps above, it will not stick with the cell in case you resize, filter, or hide the cells. If you want the image to stick to the cell, you need to lock the image to the cell it’s placed n.
To do this, you need to follow the additional steps as shown below.
Right-click on the picture and select Format Picture.
In the Format Picture pane, select Size & Properties and with the
options in Properties, select ‘Move and size with cells’.
Now you can move cells, filter it, or hide it, and the picture will also move/filter/hide.
NOTE:
This answer was taken from this link: Insert Picture into a Cell in Excel.
While my recommendation is to take advantage of the automation available from Doality.com specifically Picture Manager for Excel
The following vba code should meet your criteria. Good Luck!
This code will insert the image into the chosen cell and will scale it to fit the exact width and height of the cell. For example:
Instructions:
Add a Button Control to your Excel Workbook (click Developer tab, Insert, Active X, Command Button) and then double click on the button in order to get to the VBA Code -->
Sub Button1_Click()
Dim filePathCell As Range
Dim imageLocationCell As Range
Dim filePath As String
Set filePathCell = Application.InputBox(Prompt:= _
"Please select the cell that contains the reference path to your image file", _
Title:="Specify File Path", Type:=8)
Set imageLocationCell = Application.InputBox(Prompt:= _
"Please select the cell where you would like your image to be inserted.", _
Title:="Image Cell", Type:=8)
If filePathCell Is Nothing Then
MsgBox ("Please make a selection for file path")
Exit Sub
Else
If filePathCell.Cells.Count > 1 Then
MsgBox ("Please select only a single cell that contains the file location")
Exit Sub
Else
filePath = Cells(filePathCell.Row, filePathCell.Column).Value
End If
End If
If imageLocationCell Is Nothing Then
MsgBox ("Please make a selection for image location")
Exit Sub
Else
If imageLocationCell.Cells.Count > 1 Then
MsgBox ("Please select only a single cell where you want the image to be populated")
Exit Sub
Else
InsertPic filePath, imageLocationCell
Exit Sub
End If
End If
End Sub
Then create your Insert Method as follows (this can follow the button's code from above):
Private Sub InsertPic(filePath As String, ByVal insertCell As Range)
Dim xlShapes As Shapes
Dim xlPic As Shape
Dim xlWorksheet As Worksheet
If IsEmpty(filePath) Or Len(Dir(filePath)) = 0 Then
MsgBox ("File Path invalid")
Exit Sub
End If
Set xlWorksheet = ActiveSheet
Set xlPic = xlWorksheet.Shapes.AddPicture(filePath, msoFalse, msoCTrue, insertCell.Left, insertCell.Top, insertCell.Width, insertCell.Height)
xlPic.LockAspectRatio = msoCTrue
End Sub
You can do it in a less than a minute with Google Drive (and free, no hassles)
• Bulk Upload all your images on imgur.com
• Copy the Links of all the images together, appended with .jpg. Only imgur lets you do copy all the image links together, do that using the image tab top right.
• Use http://TextMechanic.co to prepend and append each line with this:
Prefix : =image(" AND
Suffix : ", 1)
So that it looks like this =image("URL", 1)
• Copy All
• Paste it in Google Spreadsheet
• Voila!
References :
http://www.labnol.org/internet/images-in-google-spreadsheet/18167/
https://support.google.com/drive/bin/answer.py?hl=en&answer=87037&from=1068225&rd=1
Related
I am trying to link and insert a picture (*.png) into a shapes fill in powerpoint using vba in Excel. In the end I will loop through this on 100+ pages and the pictures will be updated frequently so automating this will be a huge time saver. Currently I have figured out how to loop through the pages and insert the pictures into the shapes, but I have been unable to figure out how to link the pictures too.
I'm using the below code to fill the shape with the picture but I can't find the syntax to both insert and link it:
Pres.Slides(1).Shapes(ShapeName).Fill.UserPicture PictureFilePath
Ultimately this should behave like clicking on a shape, going format > shape fill > picture > insert and link (On the drop down next to insert in the dialog box).
Not all user interface actions are in the VBA object model. One of those exceptions is creating a link to a shape fill. The closest you can get is to link pictures that are inserted as pictures rather than as fills. Here's the syntax to add a linked picture. It assumes the picture is in the same folder as the presentation:
Sub Macro1()
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="Picture1.png", LinkToFile:=msoTrue, SaveWithDocument:=msoFalse, Left:=300, Top:=251, Width:=121, Height:=38).Select
End Sub
Welcome to SO.
For answering your question, I'll give some credit to this similar SO question based on Excel and this similar SO question based on PP. Some additional information was gathered from the microsoft documentation on the subject.
What you seem to be looking for is the ActionSetting object in the shapes class, which seems to be availible to shapes in PowerPoint. Below is a code snippet created directly in PowerPoint VBA
Sub insertPictureIntoShapeWithLinkToPicture()
Dim PP_Slide As Slide, PP_Shape As Shape, imagePath As String
Set PP_Slide = ActivePresentation.Slides(1) 'Set slide (change as necessary)
Set PP_Shape = PP_Slide.Shapes(1) 'Set shape (change as necessary)
imagePath = "Path to image"
With PP_Shape
'add picutre
.Fill.UserPicture imagePath
'Set an action on click
With .ActionSettings(ppMouseClick)
'Set action to hyperlink
.Action = ppActionHyperlink
'Specify address
.Hyperlink.Address = imagePath
End With
End With
End Sub
The same approach should be available via Excel, either adding a reference to the PowerPoint object library, or using Late-Binding methods. Note that the 'click' method with hyperlink defaults to standard hyperlink clicking (ctrl + left mouse for windows with a Danish keyboard).
Please find attached code.
First create a shape in PPT and run the code.
Is it possible to create a hyperlink within an Excel cell which only uses a section of the cell text for the clickable link? I.E. would the below table mockup represent something that can be easily built in Excel 2010?
a mock up http://dl.dropbox.com/u/14119404/misc/Microsoft%20Excel%20-%20Book1_2012-04-16_14-24-47.jpg
I know that an entire cell can be made into a hyperlink easily, but not a specific part of the cell as far as I know.
By hyperlink I also refer to either
(a)another cell or,
(b)a web URL.
Thanks
After creating the hyperlink you could format the text in the cell so that only the words of interest are underlined/blue. The hyperlink will still work, but obviously you can still have only one link per cell, and clicking anywhere in the text will trigger the hyperlink.
For example:
Sub Tester()
Dim rng As Range
Set rng = ActiveSheet.Range("A1")
rng.Parent.Hyperlinks.Add Anchor:=rng, Address:="", SubAddress:= _
"Sheet1!A10", TextToDisplay:="this is long text"
With rng.Font
.ColorIndex = xlAutomatic
.Underline = xlUnderlineStyleNone
End With
With rng.Characters(Start:=9, Length:=4).Font
.Underline = xlUnderlineStyleSingle
.Color = -4165632
End With
End Sub
I needed to link to a filename displayed in a cell, so here is what worked for me:
ActiveSheet.Hyperlinks.Add Anchor:=Cells(row, column), Address:=file.Path, TextToDisplay:=file.Path
This isn't possible in Excel. Hyperlinks are associated with entire cells.
If you look at the documentation for the Excel hyperlink object, you can see that it's associated with a Range. If it were possible to associate hyperlinks with a span within the cell, the Hyperlink object would need to have an associated Range and Characters object.
The above one liner was very helpful... since I'm new, I couldn't comment. So here is my variation of the above that takes each row on a worksheet and builds a URL from a value on the row.
CHGRow = 3
Worksheets("Page 1").Select
Cells(CHGRow, 1).Select
Do Until Application.CountA(ActiveCell.EntireRow) = 0
URLVal = "https://our_url_here?some_parameter=" & Cells(CHGRow, cNumber)
URLText = Cells(CHGRow, cNumber)
ActiveSheet.Hyperlinks.Add Anchor:=Cells(CHGRow, cURL), Address:=URLVal, TextToDisplay:=URLText
CHGRow = CHGRow + 1
Cells(CHGRow, 1).Select
Loop
I'd just make your one row into two rows, merge the cells in the columns you need to have it appear to be a single row and when you get to the cell that needs the hyperlink then you put the words on the top cell and the link in the cell below. It will look fine as a non-techy workaround.
Here's a great smoke-and-mirrors solution I've used for creating hyperlinked strings within a larger block of text in an Excel spreadsheet cell. CAUTION -- if there are multiple editors for your worksheet, this is not advisable as hyperlinks can get misaligned with the text in their cells unless you can provide sufficient protection. A means of doing that is described in this procedure though may limit what contributors can do:
In your Excel spreadsheet, assuming you are not trying to protect ALL cells from editing, select all cells in the worksheet, then select Format Cells from the Home ribbon or the right-click popup menu. On the Protection tab, check then uncheck the "Locked" checkbox to ensure all cells are unlocked.
Now select the (first) cell that will contain the link.
Copy (don't cut) the text that you want to appear as a link to the clipboard.
Click anywhere in your spreadsheet (an unused area is best) and insert a text box from the Insert ribbon using either the Shape icon dropdown or the Text icon. Size and shape aren't important yet, just approximate the size of the link text.
Paste the clipboard contents into the text box.
Right click the text box and select Link to add a hyperlink to it, and specify the link target, whether a location in the current document or a URL.
Select the link text and format it how you want your links to appear, e.g. blue, underlined, etc., since inside a text box this apparently does not occur automatically as in a cell.
Right click the text box again and select Format Shape. From the Format Shape panel, perform the following in order to properly fit the shape around the text and eliminate white space and border:
(a) On the Fill & Line panel (1st icon), select the No Line option.
(b) On the Size & Properties panel (3rd icon), set all 4 margins to zero (0.00"), uncheck the "Wrap text in shape" checkbox, and check the "Resize shape to fit text" textbox."
(c) Under Properties, ensure the following are selected:
* Move but don't size with cells
* Locked
* Lock text
If you need the same hyperlink to occur in multiple cells or locations within the same cell (even if targets differ), clone the text box you did all this work on by selecting its (now invisible) border with a right click (warning - a left click will now take you to the link target instead!), copying it to the clipboard, and press Ctrl+V as many times as you need copies.
Right click on the text box (or one of them if you cloned it) and drag it to the cell where you want the link to appear, positioning it directly over the original text that matches your hyperlink, so as to visually cover it up and replace it (the original text serving as a spacer to make room for it). The steps taken in item 8 above should prevent it from covering up or clipping any text or punctuation surrounding the original text.
Select that cell, then from the Format menu on the Home ribbon, select "Lock Cell" to protect its contents from inadvertently changing and misaligning the text box with the corresponding text that its hiding.
Repeat steps 10 & 11 for each additional copy of the linked text box you created. If any of them requires a different link target, simply right click that copy of the text box, select "Edit Link", and update the target.
From the Format menu on the Home ribbon, select "Protect Sheet". Check the box labelled "Protect worksheet and contents of locked cells".
Check all the other boxes in that dialog also (assuming you are not trying to restrict users in any of those ways) except for the following:
* Format cells
* Format columns
* Format rows
* Edit objects
Leave these four checkboxes unchecked so as to protect your linked text boxes from being selected, deleted, moved, or misaligned with their underlying text. (Note: They should already move with their underlying cells if rows or columns are added, removed or resized, but without this protection they can still be impacted if their own row or column is resized.)
If you want to add a password, do so now. When finished, click OK to apply protection. You can selected "Unprotect Sheet" from the Format menu later to perform any necessary editing, but if the link cell(s), column(s) or row(s) are edited or resized, you may need to reposition the link text box(es) over the underlying text if it moved.
Test your hyperlink(s) and also what happens if you try editing the containing cell(s) or resizing the containing column(s) or row(s) to be sure the worksheet is ready for sharing!
I am working in excel and I want to make a Hyper Link from the top of the page to another location on the page.
I type in a box at the top, and then right link and go down to hyper link in the dropdown menu I click it and select the tab that says "In This Work Book" and change it to where I want it to go. So all this is good and all but my Question is:
Can I make a Hyper link to bring me to a cell and scroll the window so the selected cell is the first row, instead of being near the bottom of the window?
Example:
Hyper link: "Test" Located in Cell A,1
Location Of Hyper Link: A,210
Now instead of having it put A,210 at the very Bottom and show the cells above it, I want to to be at the top and show the cells below it.
Thanks for the help,
Add the following VBA code to your worksheet:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ActiveWindow.ScrollRow = ActiveCell.Row
End Sub
By magic, when you click a link, that cell will be at the top. If you don't want this behavior for all links, you can test the Target address.
You will have to save the code as a xlsm file so that macros are enabled. Use Alt-F-11 to open the VBA editor so you can actually add the code (double click the worksheet in the left hand pane, then paste the above code in the window that opens).
I am doing a large amount of data entry but down a list which is already populated i.e. I am changing slightly the entries if they meet certain requirements.
I was wondering if anyone knew of a way to get a cell to change colour once it has been selected?
The work flow I want is:
Select cell at the top --> make alteration if necessary --> press enter to go down to next cell --> the cell changes from red to green.
The idea is that when I take a break or check different values in the same excel sheet I can very easily find where I left off without having write down the row number.
It's much easier to change colour of the cell when you select it (rather than after deselecting). To do this:
Right-click the sheet tab
Click 'view code'
Paste the following into the window that pops up:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target.Interior.ColorIndex = 33
End Sub
Try it.
Is it possible to create a hyperlink within an Excel cell which only uses a section of the cell text for the clickable link? I.E. would the below table mockup represent something that can be easily built in Excel 2010?
a mock up http://dl.dropbox.com/u/14119404/misc/Microsoft%20Excel%20-%20Book1_2012-04-16_14-24-47.jpg
I know that an entire cell can be made into a hyperlink easily, but not a specific part of the cell as far as I know.
By hyperlink I also refer to either
(a)another cell or,
(b)a web URL.
Thanks
After creating the hyperlink you could format the text in the cell so that only the words of interest are underlined/blue. The hyperlink will still work, but obviously you can still have only one link per cell, and clicking anywhere in the text will trigger the hyperlink.
For example:
Sub Tester()
Dim rng As Range
Set rng = ActiveSheet.Range("A1")
rng.Parent.Hyperlinks.Add Anchor:=rng, Address:="", SubAddress:= _
"Sheet1!A10", TextToDisplay:="this is long text"
With rng.Font
.ColorIndex = xlAutomatic
.Underline = xlUnderlineStyleNone
End With
With rng.Characters(Start:=9, Length:=4).Font
.Underline = xlUnderlineStyleSingle
.Color = -4165632
End With
End Sub
I needed to link to a filename displayed in a cell, so here is what worked for me:
ActiveSheet.Hyperlinks.Add Anchor:=Cells(row, column), Address:=file.Path, TextToDisplay:=file.Path
This isn't possible in Excel. Hyperlinks are associated with entire cells.
If you look at the documentation for the Excel hyperlink object, you can see that it's associated with a Range. If it were possible to associate hyperlinks with a span within the cell, the Hyperlink object would need to have an associated Range and Characters object.
The above one liner was very helpful... since I'm new, I couldn't comment. So here is my variation of the above that takes each row on a worksheet and builds a URL from a value on the row.
CHGRow = 3
Worksheets("Page 1").Select
Cells(CHGRow, 1).Select
Do Until Application.CountA(ActiveCell.EntireRow) = 0
URLVal = "https://our_url_here?some_parameter=" & Cells(CHGRow, cNumber)
URLText = Cells(CHGRow, cNumber)
ActiveSheet.Hyperlinks.Add Anchor:=Cells(CHGRow, cURL), Address:=URLVal, TextToDisplay:=URLText
CHGRow = CHGRow + 1
Cells(CHGRow, 1).Select
Loop
I'd just make your one row into two rows, merge the cells in the columns you need to have it appear to be a single row and when you get to the cell that needs the hyperlink then you put the words on the top cell and the link in the cell below. It will look fine as a non-techy workaround.
Here's a great smoke-and-mirrors solution I've used for creating hyperlinked strings within a larger block of text in an Excel spreadsheet cell. CAUTION -- if there are multiple editors for your worksheet, this is not advisable as hyperlinks can get misaligned with the text in their cells unless you can provide sufficient protection. A means of doing that is described in this procedure though may limit what contributors can do:
In your Excel spreadsheet, assuming you are not trying to protect ALL cells from editing, select all cells in the worksheet, then select Format Cells from the Home ribbon or the right-click popup menu. On the Protection tab, check then uncheck the "Locked" checkbox to ensure all cells are unlocked.
Now select the (first) cell that will contain the link.
Copy (don't cut) the text that you want to appear as a link to the clipboard.
Click anywhere in your spreadsheet (an unused area is best) and insert a text box from the Insert ribbon using either the Shape icon dropdown or the Text icon. Size and shape aren't important yet, just approximate the size of the link text.
Paste the clipboard contents into the text box.
Right click the text box and select Link to add a hyperlink to it, and specify the link target, whether a location in the current document or a URL.
Select the link text and format it how you want your links to appear, e.g. blue, underlined, etc., since inside a text box this apparently does not occur automatically as in a cell.
Right click the text box again and select Format Shape. From the Format Shape panel, perform the following in order to properly fit the shape around the text and eliminate white space and border:
(a) On the Fill & Line panel (1st icon), select the No Line option.
(b) On the Size & Properties panel (3rd icon), set all 4 margins to zero (0.00"), uncheck the "Wrap text in shape" checkbox, and check the "Resize shape to fit text" textbox."
(c) Under Properties, ensure the following are selected:
* Move but don't size with cells
* Locked
* Lock text
If you need the same hyperlink to occur in multiple cells or locations within the same cell (even if targets differ), clone the text box you did all this work on by selecting its (now invisible) border with a right click (warning - a left click will now take you to the link target instead!), copying it to the clipboard, and press Ctrl+V as many times as you need copies.
Right click on the text box (or one of them if you cloned it) and drag it to the cell where you want the link to appear, positioning it directly over the original text that matches your hyperlink, so as to visually cover it up and replace it (the original text serving as a spacer to make room for it). The steps taken in item 8 above should prevent it from covering up or clipping any text or punctuation surrounding the original text.
Select that cell, then from the Format menu on the Home ribbon, select "Lock Cell" to protect its contents from inadvertently changing and misaligning the text box with the corresponding text that its hiding.
Repeat steps 10 & 11 for each additional copy of the linked text box you created. If any of them requires a different link target, simply right click that copy of the text box, select "Edit Link", and update the target.
From the Format menu on the Home ribbon, select "Protect Sheet". Check the box labelled "Protect worksheet and contents of locked cells".
Check all the other boxes in that dialog also (assuming you are not trying to restrict users in any of those ways) except for the following:
* Format cells
* Format columns
* Format rows
* Edit objects
Leave these four checkboxes unchecked so as to protect your linked text boxes from being selected, deleted, moved, or misaligned with their underlying text. (Note: They should already move with their underlying cells if rows or columns are added, removed or resized, but without this protection they can still be impacted if their own row or column is resized.)
If you want to add a password, do so now. When finished, click OK to apply protection. You can selected "Unprotect Sheet" from the Format menu later to perform any necessary editing, but if the link cell(s), column(s) or row(s) are edited or resized, you may need to reposition the link text box(es) over the underlying text if it moved.
Test your hyperlink(s) and also what happens if you try editing the containing cell(s) or resizing the containing column(s) or row(s) to be sure the worksheet is ready for sharing!