Basically I have a gigantic excel spread sheet with over 20,000 URL's. It would be very inefficient of me to click on each link to check the image. Instead I was wondering if I could take the url from one cell and load the image into a different cell. This of course would have to be a loop as I have so many images to load. So far I found a thread on this already but I have no idea how to implement this code.
How to get images to appear in Excel given image url
If someone could tell me how to use this code that would be great and you will also save my sanity. Thanks!
While your Excel sheet is open, press ALT+F11 (Edit: Not Ctrl)
This will open the Visual Basic editor. From there, locate the project explorer to the left side of the screen. It should appear something like VBAProject (YourWorkBookName.XLS)
right click it and select Insert -> Module.
You should see a blank white space for you to put code in. Just paste the code you found from the other post, but make sure you paste it inside a SUB definition , like this:
Sub AnyNameCanBeChoosen()
' Paste your code Here
End Sub
Then press F5 to execute your code.
Related
I know my way around Excel but I've never worked with Macros/VBA before.
I have a workbook where I input data for payment transactions which should convert to a .txt file (after pressing a button) with the data so that I can use it for batch payments.
When I press the button to convert to Excel, it throws the error "Cannot run the macro "***". The macros may not be available in this workbook or all macros may be disabled."
I've tried enabling things through the Trust Centre.
I did a bit more digging and saw that there was no code. I wonder how this happened.
I found and watched this video and was able to do the conversion.
Now my issues are:
From the video, I need to specify a worksheet name and a range for where the data is. Is there a way to do this without having to change that individually for each sheet?
If I save the sheet anywhere except the Downloads folder, it throws the error "Bad file name or number" (Error 52)
I had a saved, working copy at 11:53. Now, when I click the button to do the conversion, it doesn't work as in the button doesn't respond at all. I go into design mode and see that the code is there but the button doesn't work.
Any advice/help would be greatly appreciated.
I tried adding the other locations as Trusted Locations in the Trust Centre
I ran the code straight from VBA instead of pressing the button
I want to Google search a term. So, I did a concatenate formula that creates a hyperlink. It looks something like:
=CONCATENATE("https://www.google.com/search?q=",A1)
Where A1 is the location of the term I want to search.
So far, so good. This gives me a hyperlink in text form. Then, I create a second column to establish the actual hyperlink:
=HYPERLINK(location of the concatenate formula result)
Great. I've got a working hyperlink. If I use the mouse to click that formula, it opens the Google search correctly.
Now, I want to use the keyboard instead of my mouse to click this hyperlink. I need to do a bunch of these types of searches. Maybe I'll create a macro that can open them for me a few at a time.
Anyway, this older post describes a way of opening hyperlinks in Excel without using the mouse. The problem I have is that I don't see "Open Hyperlink" in my context menu. All I've got is "Remove Hyperlink".
Any ideas why and what I can do to work around it? Thanks!
Is there a way to force excel from automatically "rewriting" the address of the external reference?
Example
When I mouse over and select a table in another workbook as a source, the formula bar shows this:
=[WorbookName.xlsx]SheetName!TblName
Once I hit enter, the formula bar shows this:
=WorbookName.xlsx!TblName [#Data]
Brackets and sheet names get removed and [#Data] gets added.
I confirmed that excel understands the address with the sheet name by using indirect and forcing excel to use the full reference
=INDIRECT([WorbookName.xlsx]SheetName!TblName)
So its not a limitation by excel. However this only proved that excel can handle that style of reference. The problem is that when you use indirect, youre not actually creating a "link" to the source file, your workbook will never ask to update the values if the source file is closed.
I need to force excel to keep the table name in the reference because I will be uploading to OneDrive and co-authoring the workbook. When you reference a table in another workbook, and that workbook is closed, the reference is changed to include the web address of your OneDrive like this
source file open: =WorbookName.xlsx!TblName [#Data]
source file closed: =https://d.docs.live.net/location/FileName.xlsx'!TableName
I believe this is causing errors, preventing excel from updating the values. when I first open the workbook that contains the links, it will try to update to the latest data. When I use regular ranges, it has no issues. When I use tables, I get "we cant update some of the links in your workbook right now". If you go to edit the links, it looks like this:
Edit Link
If you try to update the values, you are shown this, Notice it is looking for a worksheet but the name its expecting is actually the name of the workbook.
Select Sheet
I believe this is because when you reference a range, the address is written like this:
Rance referance =https ://d.docs.live.net/Loacation/[FileName.xlsx]SheetName!$A$1:$D$20
table referance =https ://d.docs.live.net/location/FileName.xlsx'!TableName
Notice there is a difference in the location of exclamation ! point. I believe this is the reason why excel shows the workbook name as the worksheet is looking for. again if you use indirect, youre able to force excel to use the "long" address, so we know excel recognizes it with no issues.
Really hoping to find a solution, thanks in advance!
This is an alternative to what you're trying to do.
I did some tests and if the file is saved in OneDrive, you could have it open (from OneDrive not locally) and just refresh the data with PowerQuery.
Steps to create the query:
In Chrome:
Locate the source file in Onedrive (aka: https://onedrive.live.com/)
In google Chrome, download the file (we need to get the download link in the next step)
Click the elipsis in Chrome's top right corner and click on Downloads (or press Ctrl + J)
Right click the link of the downloaded file, and select Copy
In Excel...
Click Data | Get Data | From other sources | From web (I don't have the english version right now, but you should be able to locate it)
Paste the URL
Click Ok
Select the Sheet/Table (do any transformation you may require)
Click Close and Load to...
Select a sheet or any location
Press Ok
Now do any formulation against that table
As said, I did some tests with the file opened in another instance and then refreshing the table, and it worked.
Let me know if yours do.
EDIT:
As per your comments, (though I didn't test it) I did some research on how to make this work with the default sharing links.
Here are the steps:
In Chrome:
Locate and select the source file in Onedrive (aka: https://onedrive.live.com/)
Click on Share and generate the view/edit link
Copy that link
As of this date, the link should look something like this:
https://1drv.ms/x/s!ArAKssDW3T7wnIIEvmhHrMxfvhowww?e=UsaATm
The key here is to replace the ms with ws, so the link that you need to use in Excel should be something like this:
https://1drv.ws/x/s!ArAKssDW3T7wnIIEvmhHrMxfvhowww?e=UsaATm
In Excel:
Click Data | Get Data | From other sources | From web (I don't have the english version right now, but you should be able to locate it)
Paste the URL
Click OK
Righ click the icon that says 1dr.ws
Select and click Excel
Continue with the other transformations
I created a custom ribbon tab on my Excel like Excel_app_v1.xlsm, and a button under this ribbon tab is connected to a macro. So when I click this button, the macro does some table importing applications.
The first strange thing is that I created this ribbon tab and the button for only this Excel file, but the ribbon tab and the button appear in all other Excel files, even if the original Excel file Excel_app_v1.xlsm is not open.
The second problem is that I created a second version of my previous Excel file with "Save-as" option. So the new Excel file is like Excel_app_v2.xlsm. When I click the button under the ribbon tab, it opens the first Excel file Excel_app_v1.xlsm, even if it is not open. I deleted the first Excel file, but then I got an error like "Couldn't find the Excel_app_v1.xlsm on the path".
So obviously the macro button under the customized ribbon tab is linked to the first Excel file, but I couldn't find the menu option to change this. I added ThisWorkbook before all the sheet expressions in the vba code, but it didn't solve the problem. The button-click is still trying to open the old excel file.
The VBA code is below. The button is linked to the Sub ImportTable. Firstly it asks the user if the user wants to continue with the process. It opens the previous Excel file right after clicking on the button, at the same time as the Message Box appears.
Sub ImportTable()
Application.ScreenUpdating = False
YearMonth = ThisWorkbook.Sheets("tab1").Cells(11, 2).Value
' The Macro button opens the previous Excel file before clicking Yes or No on the message box
answer = MsgBox("Warning! Brings the newest source file. You want to continue?", vbYesNo + vbQuestion, "")
If answer = vbYes Then
RunSASCodeViaBatFile ' Another Sub which runs bat file to run a SAS-code. But it doesn't matter. Because the problem happens before I click on Yes or No.
InsertSASFileIntoExcel
Else ' Nothing happens if clicking No on the Message Box
End If
End Sub
The clue to fixing this quickly was posted below by roncruiser, with one slight twist.
Everyone on the web seems to feel that PERSONAL.XLSB is the key here — nope. In fact, playing with that file only confounded me for even longer. Here's what I did instead:
Right click the Ribbon and select Customize The Ribbon;
Navigate to the offending macros that you've installed with buttons;
Find and click on Import/Export;
Export your custom buttons (the macros will go right along just fine);
Open that resulting file, and edit out the offending references to the other file that's causing you so much grief — example:
<mso:button idQ="x1:HideRows_0_EA10D6" label="HideRows" imageMso="_3DPerspectiveDecrease" onAction="!HideRows" visible="true"/>
I took out everything after idQ-"x1... up to the actual name of the macro. I also took out the same external reference found in onAction="... Take everything up to the bang mark.
Save this under whatever name you wish, but with the same extension (for my setup, it was called ExportedCustomizations.exportedUI (yes, that long an extension));
Repeat the first few steps here, but this time import your edited file.
Voila, all is golden.
No messing around with wiping out existing work and starting all over. Worked a charm for me, so a big tip o' The Hat to roncruiser for the clue.
Just to confirm what sumgain have write above.
It works perfectly just do as he said : remove the part after the "x1:" that refers to a specific workbook until the begining of the maccro's name.
example :
When you export your custom ribbon with the maccro attached to it it will be write like below :
idQ="x1:C:_FolderName_Filename.xlsm_Fill_Formulas_Cells"
THen you remove the part mentionned and it will become like that :
idQ="x1:Fill_Formulas_Cells"
Same for onAction keep only the Maccro Name
Then it will works perfectly as long as you the maccro's name in the workbook stay consistent if you modified the Macros name then you have to modified it in the exportedUI file.
Then when you will reload the new file you can check in the Excel Options customize ribbon on the customize button if you put the pointer on you will see "Maccro: Name of your maccro"
And not the path of the file the maccro was from.
No need to use custom UI editor or any other things such as personnal maccro at least for that and if you are not bother to have custom ribbon in all of your woorkbook.
As well it is obvious but still good to remind it, you need to have the maccro in the workbook this procedure is just there to call the maccro that are associate to the workbook, it doesn't contain the code of the maccro.
Cheers
Romain
Does this still work? I have done this in the past with success but can't seem to get it to work now.
I export the file, edit it and import it back in.
it appears to work, but when i close the Ribbon options pane, my custom buttons disappear.
Same exact thing happened to me. There's a way to get around this.
By default, when you create a macro in Excel and run that macro through a custom ribbon button, that ribbon button macro works only in the workbook that contains it.
To get around this and have the button macros work in all workbooks, you'll need to create a Personal Macro Workbook. Then any macros that you store in your personal workbook on a computer become available to you in any workbook whenever you start Excel on that same computer.
Create a Personal Macro Workbook
To get the same ribbon button macros to work on another computer, you'll need to copy the Personal Macro Workbook to another computer and store it in the XLSTART folder. The link above has all the information you'll need.
Note: Delete the old ribbon button macros. Make sure you create new ribbon button macros that reference the macros from your Personal Macro Workbook.
Does anyone know of a pre-packaged solution for referencing Excel cells directly in a Word document?
For example,
{[TestExcel]Tab1!A1}
Dear Mr. {[TestExcel]Tab1!A2},
Our systems have alerted us that your account {TestExcel]Tab1!AccountNumber} is overdue. Please remit payment of {TestExcel]Tab1!PaymentDue} immediately.
This example uses a hypothetical { } syntax, where the contents are standard Excel formula.
Every solution I've seen uses custom VBA to accomplish this. It seems like an extremely common need for which there should be some good 3rd party software available that lets non-technical users accomplish this task.
As indicated in the example above both named ranges and standard cell references would need to be supported.
Yes.
Step 1: Copy the excel cell.
Step 2: Go to your word document where you want to paste the reference.
Step 3: Right click
Step 4: Under paste options, select "link with source formatting" or "link and merge formatting".
I tried #Green Demon's method, but the two Paste Options listed were not present for me (Office 2013). I only had Keep Source Formatting, Merge Formatting, and Keep Text Only. However, I poked around and found the Paste Special, which was hidden on the Ribbon
The instructions are as follows:
Copy the Excel range.
Go to your Word document, and left click where you want to paste the Excel range.
Click on Paste Special from the Ribbon as shown below, or type Ctrl+Alt+V.
Click on the Paste link radio button.
Click on Microsoft Excel Worksheet Object. The Paste Special dialog box should look something like this:
Click OK.
The range should now be pasted in your document, and if you save, close, and re-open the Word document, you will be prompted about whether or not you want to "update this document with the data from the linked files," which works the same way as it does if you're doing Excel-to-Excel linking.
This feature is fantastic, and I'm so happy to have found it today. However, in my brief experience using it, having these Word-to-Excel links dramatically increases the amount of time it takes to open your Word document, even before it prompts you about updating. After that, the act of updating the Excel links takes much longer than it would if you were doing the same linking Excel-to-Excel. All of my work is done on network-share files, so YMMV.
While Will's solution indeed links from the Cell objet, the content is inserted as a picture.
In the same dialog, selecting "Unformatted Unicode Text" instead will link and insert only the cell's content, which is desirable if you apply custom formatting on your text.
Unfortunately, this action only works for a single cell. Copying multiple cells will result in a text block with individual cell content seperated by tabs or line skip, with the entire block considered linked and entire. The solution is to link individual cells using this method.
This can become tedious if you plan on linking large portions of table from Excel, as for every cell the dialog must be invoked. It can be sped up by using hotkeys, but the sequence gets tedious:
alt,h,v,s, then alt+l, tab, ↓, and finally Enter
Obviously this is not practial for large numbers of cells. A AutoHotkey script can help but it third party grafted solution, on par with using VBA scripts.
alt+h+v+l works too. If you're building big documents clicking the ribbon every time gets murderous after a while.
As this is still a problem but the other answers do not take into account the latest development in word, there is a new solution, editing Green Demons answer:
Step 1: Copy the excel cell.
Step 2: Go to your word document where you want to paste the reference.
Step 3: go to the "home" tab
Step 4: Under paste options, go to "Paste Special", click on "paste link", click on "Unformatted Text".
This solves the issue others were having with the new lines that you would otherwise have with just Green Demons' solution.
Hope this still helps others.