Microsoft Excel Search Engine - Hyperlink Results Provides Error Message - vba

I've been trying for two days to figure out this problem.
I have created an Excel search engine to search through a database of hyperlinks in the same worksheet. I want the results to display working hyperlinks, but right now it just displays the text. When the hyperlink is clicked, I get an error message - "Cannot open the specified file."
Can someone please help me. I've tried multiple codes including the following:
=HYPERLINK("#"&VLOOKUP(D5,A2:C91,3,FALSE),""""))) to no avail.
I can also email the spreadsheet if a email is provided. Thank you!

A hyperlink cannot start with the # sign. If the link is to a file, then you need to start with the file path, like shown in the Excel help
=HYPERLINK("D:\FINANCE\1stqtr.xlsx", H10)
If the link goes to another sheet in the same file, use
=HYPERLINK("[Budget.xlsx]E56", E56)
The Vlookup will need to return the correct file path or a valid URL, including the "http://"

Related

vba code - Replace text in html email without breaking formatting

I am trying to replace specific text in an email (skype meeting invite) with a custom piece of text that is a URL. I can do this fine for plain text via a vba macro in outlook click to run (2016/2019), but if I run the below against the expected html email that the meetings create it breaks the formatting completely.
Sub ChangeS4bMeeting()
Application.ActiveInspector.CurrentItem.body = Replace(Application.ActiveInspector.CurrentItem.body, "Conference ID: ", "https://linkhere")
End Sub
It ends up replacing the text correctly and adding what follows that space after the colon to the replaced text as the URL, but formatting of the whole invite email breaks.
I have tried using "HTMLBody" value instead of "body" value but this fails to run at all as it breaks on that line. Any ideas? Would it also be possible to have this run automatically when I selected New Items > Skype Meeting in outlook rather than running the macro manually (or have the macro include the creation of a skype meeting directly)?
Thanks in advance!
You must ensure that the content placed in the HTMLBody is properly formatted and that any such text is placed between the and tags in the HTMLBody.
For more information, please see the following link:Find and Replace as a VBA Macro
You can create custom rules that execute scripts to implement specific conditions for executing the script.
please see the following link: Create a Custom Rule executing a Script

Get upercase within String Value

I am currently working on a tool to automatically send out emails.
Within this tool one variable is the pathway in which the attachment is to be found.
The file names are automatically generated within a folder, but sometimes got strange symbols and/or uppercase letters, like this: "Sⁿkwrld.xlsx".
By collecting this value within a string, VBA retrieves: "Snkwrld.xlsx". This results in not being able to find the right file.
Is there a way to fix this problem and let VBA retrieve the correct value with the uppercase "N"?
Thanks in advance!
Best Regards,
Remco Coppens

Modify range of Hyperlinks in Excel

So, I have a spreadsheet that I have sent out to several of our staff asking to update certain fields/columns. I have a Document Link field (Column G) which links them a folder in our F: Drive which they can use to help populate the necessary fields.
The spreadsheets which I want them to complete are also in this F:Drive. However, I noticed each of the document links no longer work, and when I check the link under Edit Hyperlink, I notice instead of the desired "*F:\Procurement..." I have my home drive "+\NSH-HDRIVES1..." as the header,
F:\Procurement\Contracts\Alco...xxx...
\NSH-HDRIVES1\Contracts\Alco...xxx...
I have hundreds of these lines with document links that need "\NSH-HDRIVES1" replaced with "F:".
Is there some kind of VBA Macro that will let me do this? I have little experience and time to learn VBA Macros at this point so any help would be greatly appreciated. Note each link is different and goes to a different folder within our F:Drive, all I need is to change the prefix.
Thanks and sorry for any duplication.
The following code may help, but it is set up to only work on the ActiveSheet. If your hyperlinks are in multiple workbooks and multiple worksheets you will need to loop through them all.
For Each h In ActiveSheet.Hyperlinks
h.Address = Replace(h.Address, "\NSH-HDRIVES1\", "F:\Procurement\")
h.TextToDisplay = Replace(h.TextToDisplay, "\NSH-HDRIVES1\", "F:\Procurement\")
Next

Excel VBA - Extract/Open a dynamic hyperlink URL/Address

Greeting!
I am attempting to use excel vba to extract a dynamic hyperlink from OR use excel vba to open the dynamic hyperlink in a worksheet. I am able to click the hyperlink and it will open up correctly. So far, I am not able to find any relevant information pertaining to how to extract the URL the hyperlink is pointing to or simply open the hyperlink.
Here is the formula that is used to build the dynamic hyperlink based on a model selection.
=IFERROR(HYPERLINK(VLOOKUP(S.O.P.!$D$3,Models!$C$2:$G$296,4,FALSE), "Click Here to Open Box Label"), "Unable to retrieve part information")
So based on a selection the user makes this formula goes and finds the respective link that will be used to create the hyperlink.
What I want: Using a button - open the file(PDF) to allow the users to easily print the files they need from one button. I am trying to minimize human touches to eliminate the possibility for human errors.
I have also attempted to record a macro to open up the link, but it only takes me to the worksheet that the hyperlink is placed in.
Here are links to other post that were not able to resolve my issue, but provided good information...
Excel VBA Get hyperlink address of specific cell
Extract URL From Excel Hyperlink Formula
Thank you, I look forward to some helpful responses c:
let me know if I need to elaborate or clarify anything!
Any reason you cant run the vlookup in VBA. Then you will have the link address as a string which you can then do what you want with:
Sub GetLink()
Dim ReturnedAddress As String
ReturnedAddress = Application.WorksheetFunction.VLookup(ThisWorkbook.Sheets("S.O.P.").Range("D3"), ThisWorkbook.Sheets("Models").Range("C2:G296"), 4, 0)
end sub

Insert image from URL bookmark Microsoft word

I have a image URL contained in my sql database.
I create a bookmark for that column in the word document (this works fine).
Now I want to use the image URL that is passed from the database to insert an image.
I have tried hyperlink (does not work and does not display image).
I have tried Quick Parts - IncludePicture (does not work).
I have been Googleing and have not found anything that works.
Ok let me simplify this.
I want to insert a image using an URL.
You can do this in alot of different ways I know.
For instance using Quick Parts and the selecting IncludePicture you would the past the URL of the picture and BAM image inserted.
Now I want to do exactly that with one exception. The URL is a microsoft word bookmark that I get from my database.
For some reason this does not want to work. I have also checked the bookmark data and it is correct and yes it is a valid URL because if I copy and paste it from the database in the way I described above it works.
So is there any other way to do this?
To be honest I still don't know where is exactly your problem. I assumed that you have knowledge and code to take both bookmark name and url from your database using VBA. If so, there would be quite simple code which would allow you to load picture from web to bookmark in your word document.
Below is the code I have tested with half of success. If I add any picture it will work fine. But will not work with url of active google map. I have no idea what you you mean with 'static google map' (in comment), you didn't provide any example therefore you need to make your own test.
Before you run this for test be sure you have two bookmarks in your active document: bookmark_logo and bookmark_poland. Hope this will help a bit.
Sub Insert_picture_To_Bookmark()
Dim mapURL As String
Dim soLOGO As String
soLOGO = "http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png"
ActiveDocument.Bookmarks("bookmark_logo"). _
Range.InlineShapes.AddPicture _
soLOGO, True, True
mapURL = "https://maps.google.pl/maps?q=poland&hl=pl&sll=50.046766,20.004863&sspn=0.22047,0.617294&t=h&hnear=Polska&z=6"
ActiveDocument.Bookmarks("bookmark_poland"). _
Range.InlineShapes.AddPicture _
mapURL, True, True
End Sub