Add embedded hyperlink to MS Access textbox in form - vba

I try to do the embed a hyperlink in a textbox (rich text) in a MS Access form . Would this be possible? Didn't found any solution in the web so far...
Something like:
Me.TextWithLink = "Text here for link <b> Hyperlink Text</b>"
PS: Textbox is set to RichText, tried to set to hyperlink true/false but not working...
Is there any workaround?

Form_Formular1.Text0.Value = "your text http://www.google.de"
Would produce automatically
As well as
Form_Formular1.Text0.Value = "your text http://www.google.de"
but obviously the URL and the hyperlink text needs to be the same. So
Form_Formular1.Text0.Value = "your text " & url & ""

Related

Microsoft Word VBA insert web link to text box in document

Is there any way I can insert an html link into a textbox using VBA? I've created a dialog with a textbox, I would like to convert the text to a web link, then insert it to the textbox in the document.
Dim WO_Box1 As Shape
Set WO_Box1 = ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, Left:=17, Top:=125, Width:=106.5, Height:=19)
WO_Box1.TextFrame.TextRange.Font.Name = "Tahoma"
WO_Box1.TextFrame.TextRange.Font.Size = "9"
WO_Box1.TextFrame.TextRange.Text = TextBox1.Text
WO_Box1.TextFrame.TextRange.Hyperlinks.Add Anchor:=WO_Box1.TextFrame.TextRange, Address:=TextBox1.Text, TextToDisplay:=TextBox1.Text
The Anchor is the textbox you are working with. You can use any text for TextToDisplay but the Address should be assigned to the actual hyperlink url.

vb.net determine if richtextbox is empty

I have a RichTextBox (RTB) that I am using to save text to a SQLite DB
To prevent the user from not entering text in the RTB I have implemented the code below
The issue is after the user enters some text in the RTB clicking the SAVE button will not bypass the test
Question is there a better way to do this and why is this code failing?
If Len(Trim(rtbEnter.Text = " ")) Then
tbMessage.ForeColor = Color.Red
tbMessage.Text = "No Data to Enter"
Return
End If

VBA Code to change font and size in an email from access

I have an access form that runs a query. There is a command button on the form that I want to send an email with the query results attached in an excel spreadsheet. Using the code below I am able to attach the results and send the email ok. I would like to be able to format the email body so that it is more noticeable. I'm not really sure how to go about doing this and still have my query attached. I have also created an email template that I would use but I haven't been able to figure out how to use the template and attach the query results. I'm open for any suggestions. Any help would be greatly appreciated.
DoCmd.SendObject acQuery, "BoxOrder", "ExcelWorkbook(*.xlsx)", "me#home.com", _
"John#hishome.com", "", "BOX ORDER", _
"ALL BOXES STITCHED" & vbCrLf & "Questions: Please Call Me" & _
vbCrLf & "555-555-5555 x 66654", True, True
You could follow the Article from MS.
A proportion of the code is as follows:
Set ola1 = New Outlook.Application
Set mai1 = ola1.CreateItem(olMailItem)
mai1.To = strTo
mai1.Subject = strSubj
If bolHTML = True Then
mai1.HTMLBody = strBody
Else
mai1.Body = strBody
End If
mai1.Display
If you use the HTML (set bolHTML = True) version you can either have an RTF control on a Form and pass the formatted text over or hardcode your HTML with the formatting you need. Just set the "strBody" to the message you want.
Then you need to look into the Attachments.Add (MS Article) if you want to use the above code with your original purpose.
There's a full 599CD Email Seminar you could follow if you're going to be doing a lot with Email in Access.

Get RichTextBox Format and use it for a replace function

I just started to learn VB and try to make a little WYSIWYG-HTML Editor. For that i already made a RichTextBox in which the user is able to change colour, fontsize etc.. Now I want to add for example a <b> -Tag before and a </b> -Tag after a word which is written in bold style, save it in a string and give back the new string in a second read-only-Textbox.
What's the best way to do this?
So you want to set read-only textbox's text to the richtextbox's text and then replace certain string with other strings?
If so, here's some code I wrote up. It's probably not the best but it works.
TextBox1.Text = RichTextBox1.Text 'Copies the text form the richtextbox to the normal textbox
If TextBox1.Text.Contains("<b>") Then 'Checks to see if Textbox1 contains the string "<b>"
TextBox1.Text = TextBox1.Text.Replace("<b>", "[b]") 'Replaces <b> with [b]
End If
If RichTextBox1.Text.Contains("</b>") Then 'Same thing as above but this checks to see if it contains "</b>"
TextBox1.Text = TextBox1.Text.Replace("</b>", "[/b]")
End If

How to convert the body of an email into a .pdf

I have to convert an email into .pdf without the head which includes the information about the date, the receivers, cc, etc.
Does anyone how to do that the easy way?
My other solution would be to copy the whole body of the mail into a new word-document and save it as a .pdf, but I don't know how to copy the whole body via VBA either.
[EDIT JMax from comments]
Here is the code I've tried:
sBody = oMail.HTMLBody
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
wrdApp.Documents.Add "C:\asd\Releasemail.dotx"
wrdApp.Documents("Dokument1").Bookmarks().Item("Releaseinhalt").Range.Text = sBody
I get my whole HTML printed in the .doc, but I want the body of the mail as it's shown in Outlook, not the markup, that creates that look. For example, if I press Ctrl + a and Ctrl + c in Outlook and press Ctrl + v in Word, I get the text with all its styling copied to Word.
How to do that in VBA?
When you want to get only the body of a mail, you have to use this kind of statement:
Dim Msg As Outlook.MailItem
Body = Msg.HTMLBody
You can find another example on this blog and on VBA Express
Have a try and come back when you will have an issue on some code.
[EDIT]
To get the body content instead of HTML, you can use : Msg.Body but you will then probably loose the formatting of the message.