I have to perform alot of searches in Google, so I made a Excel document that simply inserts the text into the google link:
"John" AND “Soccer” OR “Sport”
"Andre" AND “Soccer” OR “Sport”
For example in have the name "John"in cell A1 and I insert it in the following link.
https://www.google.nl/search?newwindow=1&q=%22&A1%22+AND+%E2%80%9CSoccer%E2%80%9D+OR+%E2%80%9CSport%E2%80%9D+&oq=%22&A1%22+AND+%E2%80%9CSoccer%E2%80%9D+OR+%E2%80%9CSport%E2%80%9D+&gs_l=serp.3...7614.32351.0.32567.17.17.0.0.0.0.345.1828.8j6j0j1.15.0....0...1c.1.64.serp..2.3.379...30i10k1.vLZ-hcrrdgg
And it comes out like this:
https://www.google.nl/search?newwindow=1&q=%22John%22+AND+%E2%80%9CSoccer%E2%80%9D+OR+%E2%80%9CSport%E2%80%9D+&oq=%22John%22+AND+%E2%80%9CSoccer%E2%80%9D+OR+%E2%80%9CSport%E2%80%9D+&gs_l=serp.3...7614.32351.0.32567.17.17.0.0.0.0.345.1828.8j6j0j1.15.0....0...1c.1.64.serp..2.3.379...30i10k1.vLZ-hcrrdgg
I made this for all the names by simply dragging it down. And these are all links that actually sends me to the page I want to be on. But what i can't is "CLICK ON THEM" no matter what i try i can't make those cells clickable Hyperlinks.
Next step is also that i want to print/Save them using Amyuni PDF. (this is not my biggest concern at the moment)
Is there any way to force the text to open up in a browser? Using VBA for example.
Thank You in advance, if you know a easier way to perform this I would like to hear that as well.
Kind Regards!
You should use the Hyperlink( ) Function
=HYPERLINK(link_location, [friendly_name])
you have this example from Microsoft, if the link you want is in A5 :
Sub test()
With Worksheets(1)
.Hyperlinks.Add Anchor:=.Range("a5"), _
Address:="http://example.microsoft.com", _
ScreenTip:="Microsoft Web Site"
End With
End Sub
you can modify Address:=... by the content of the cell
Related
I am trying to automate a repetitive manual task for another department. They have a word template several pages long. They have to enter data several times each time they use it. Many of these are repetitive "fields". I thought about setting up custom form fields. But having them go through the navigation and know the field names to update them is not optimal. I found one solution to create a bookmark for each data input, and create links to that bookmark where it needs to be repeated - better but not optimal. I was hoping to create a userform where they can enter all the data and have it populate bookmarks, custom fields, to whatever.
I found a video that does this, but when I try the code, it does not update the bookmark. i created userform with Textbox1, and a CommandButton, and a bookmark in the document called MWDate. The code I am trying to get to work is:
Private Sub CommandButton1_Click()
Dim MWDate As Range
Set MWDate = ActiveDocument.Bookmarks("MWDate").Range
MWDate.Text = Me.TextBox1.Value
Me.Repaint
UserForm1.Hide
End Sub
This is a code example I grabbed and modified from the tutorial video. I don't know what the "Me." is. It does not populate the bookmark, which tells me it is not getting to the repaint line. Nor does it ever get to the hide line.
Anyone have a fix? Or a better way? Thanks for any help you can give.
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
I'm trying to get a hyperlink to activate a macro. I can't use a fixed target address, because I've several links; The goal is to create a clickable history of taken step. So I need to create a back button.
I already tried this:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Address = "$A$4" Then
MsgBox "This isn't what I had in mind"
Else
MsgBox "MACRO!"
Exit Sub
End If
End Sub
Anybody an idea?
If I click the hyperlink it only show the code for that cell.
The code is in the Worksheet module.
The general idea:
I'm making a workbook that calculates based on several steps (40 in total). For example: if sum is larger than 9 go to step 4, if not, go to step 21.
But because we're all human and mistakes can be made, i want excel to make a list of all the steps that have been taken and their answer. I want to make the steps in this list clickable, so when they click on the step, the can go back to that step and continue from there. So a lot of hyperlinks :)
Why not use Worksheet_SelectionChange with the same setup?
This seems to work for me, I've copy and pasted your code into the "Sheet1" module of a new Excel workbook, and put a hyperlink on the 'Sheet1' tab to click on. The MsgBox pops up as expected.
I believe the macro will only work if the code is in the Sheet module for the Worksheet that the users is clicking the link on.
If you need a Hyperlink Back button, you can always add one to the Quick Access Toolbar:
This Macro doesn't work if you use =HYPERLINK(), you have to convert it via 'rightclick', Hyperlink.
How can I use VBA to return all of the formatting information about a cell in Excel. For example:
I need to know which text is purple, which is green, and which is struck through. Range("B2").Value only returns the plain text. I need the formatting as well.
your best bet is probably to use the Intellisense to explore all of the values that are available to you. You can finish off the code snippet below with things like .Color, .Strikethrough, .Bold, etc, and have them print to the immediate window. (Ctrl+G displays the immediate window if you don't currently have it displayed)
Sub test()
debug.Print Range("B1").Font 'finish this line with any of the IntelliSense options to learn things about the text
End Sub
You can also take a look at the properties listed on the MDSN site for the font object
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