Add file link to email body VBA - excel

I'd like to add a network file link to my email body using Excel VBA.
The code below add the text, but I'd like file location to be a hyperlink?
strbody_2 = "<BODY style=font-size:11pt;font-family:Calibri><b><u>" & "CapAd File:" & "</b><u>" & "<br>" _
& Sheets("Control").Range("CapAd_File") _ ' THIS IS THE FILE LOCATION
& "</b></u>"

try using the html <a>-Anchor tag:
strbody_2 = "<BODY style=font-size:11pt;font-family:Calibri><b><u>" & "CapAd File:" & "</b><u>" & "<br>" _
& "<a href=""" & Sheets("Control").Range("CapAd_File") & """>" _
& Sheets("Control").Range("CapAd_File") _ ' THIS IS THE FILE LOCATION
& "</a></b></u>"
(sorry if i didn't get the apostrophies correct i didn't test it before i posted)

Related

Pulling ListBox Data, Text and HTMLrange as Email Body

So I will try and be as clear as possible.
I am trying to make a macro that will populate and email with the following things:
Values from Listboxes
Writing for the main message
and a Table of values (which I've currently got being populated as a HTML body.
For example, I would like the email body to look as follows:
"Dear" [Name from preselected listbox]
"In order that we compile the latest update for the NAV please can you arrange the following information to be provided for" [The date]
[LIST THROUGH HTML]
"Please can you provide this information by the folowinf date"/....
I've currently got the list being pulled through correctly, but that has then stopped the vba body being entered. Therefore, the following code only pulls through the list.
Dim Addressee As String, SenRan As Range ' Define the receipient as words
Addressee = Application.VLookup(SourceLiBo.Value, Sheet1.Range("A1:B1000"), 2, False) 'finds the email address for chosen name
Set SenRan = ThisWorkbook.Sheets("Assets").Range("A1").CurrentRegion 'Selects the range of assets to be emailed.
With OEmail
.To = Addressee 'Send to addressee
.Subject = "Information Request " & Format(Date, "mmmm")
.Body = "Dear " & Me.SourceLiBo & "," & Chr(10) & _
"In order that we can compile the latest update for the NAV, please can you arrange the following information to be provided for " & Format(Date, "mmmm") & ":" & Chr(10) & _
""
.HTMLBody = rangetoHTML(SenRan)
End With
How is the best way to go about this in order to have all the data pull through. I would set variables with the strings wanted for the body and input it through .HMTLBody, but would that also allow me to pull through th listbox values in HMTLBody
I have now reworded it, thanks to braX explaining my errors. The code below (with the Ron Bruin Function) provides the correct answer.
With OEmail
.To = Addressee 'Send to addressee
.Subject = "Information Request " & Format(Date, "mmmm")
.HTMLBody = "Dear " & Me.SourceLiBo & "," & _
"<br><br>" & _
"In order that we can compile the latest update for the NAV, please can you arrange the following information to be provided for " & Format(Date, "mmmm") & ":" & _
"<br><br>" & _
rangetoHTML(SenRan) & _
"<br><br>" & _
"Please let us know if there are any additional purchases not reflected in the list above." & _
"<br><br>" & _
"Please can you provide this information no later than 10 working days from the date of this email to allow us to process all updates for delivery." & _
"<br><br>" & _
"Many Thanks"
End With

VLC playlist parameters with spaces

on my excel sheet the user can choose some video clips and arrange in different order to play as a vlc playlist. Unfortunately it can’t be guaranteed that the video file names haven’t any blanks.
To build the vlc playlist I use successfully:
Dim PL
PL = Shell("C:\Program Files\VideoLAN\VLC\VLC.exe " & certainPath & "\Movie6.flv" & " " & certainPath & "\Movie7.flv" & " " & certainPath & "\Movie8.flv ", 1)
'using "\Movie 6.flv" 'doesn't work of course
'using "\'Movie 6.flv'" 'doesn't work aswell
Is there another way to encapsulate file name with blanks?
thankfull for a hint.
Assuming that certainPath folder end with \ ( es. "C:\" ), this should work:
Dim PL
PL = Shell(chr(34) & "c:\Program Files\VideoLAN\VLC\vlc.exe " & chr(34) & chr(34) & certainPath & "Movie 6.flv" & chr(34) & " " & chr(34) & certainPath & "Movie 7.flv" & chr(34))
CHR is a function to returns the character from the ASCII table (the quotes in this case).

Update a table data link in AutoCAD using VBA

I have an issue, have an AutoCAD file with a ton of data links and would like to update only the data links related to a speciffic table.
Simmilar to the functionality of selecting a table with data links, right clicking and selecting Update Table Data Links.
i have the following code:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "K" & vbCr
End Sub
It works but updates all the data links in the drawing (which is a problem) so a perfect solution would either let me get what links are associated to tblRef
and change the line to:
ThisDrawing.SendCommand "DATALINKUPDATE" & vbCr & "U" & vbCr & "D" & vbCr & "datalink_name_from_tblRef" & vbCr
or directly send the command to update the links to tblRef
After much digging around and a lot of help, here is the answer:
Private Sub Update_table_data_link(tblRef As AcadTable)
ThisDrawing.SendCommand "DATALINKUPDATE " & vbCr & "U" & vbCr & Ent2lspEnt(tblRef) & vbCr & vbCr
End Sub
Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function
note that "Update_table_data_link" has a table as input

Save email draft in .msg format with .SaveAs

I am using a VBA code to write an email in Outlook with the information from a PowerPoint file and saving it as a draft, in the format ".msg".
With OutMail
.To = name_email
'Add file likethis
.Attachments.Add ("C:... " & numb_slide & ".pptx")
.Subject = "... " & date_c & " | Open Tasks " & name_project & " | Feedback ... " & dead_line_date & ",..."
.Body = StrBody
'.SaveAs "C:... " & CStr(date_c) & " | ... " & CStr(name_project) & ".msg", 5
.SaveAs "C:..." & numb_slide & ".msg", 5
'.Display Or use .Send
End With
I have two problems:
1) When I save the file using:
.SaveAs "C:..." & numb_slide & ".msg", 5
The program does not give me an error but I cannot open the draft that was saved, the error states:
If I create a normal email and save it as a draft, I can open it later.
2) If I change the way I save the file, like:
.SaveAs "C:... " & CStr(date_c) & " | ... " & CStr(name_project) & ".msg", 5
Or
.SaveAs "C:... " & date_c & " | Open Tasks " & name_project & ".msg", 5
It gives me the following error before finishing the task:
The variables I am writing in the name are strings, but I also tried to write them using CStr() to check if it would make any difference, and it does not!
I think you want 3 instead of 5.
From the olSaveAsType enumeration:
3 corresponds to Outlook message format (.msg)
5 corresponds to HTML format (.html)
Alternately, you could just drop the file type. From the MailItem.SaveAs documentation,
If the file type is not specified, the MSG format (.msg) is used.

Script stores procedure creating in single line [duplicate]

This question already has answers here:
How to enter newline character in Oracle?
(3 answers)
Closed 4 years ago.
I have written VBA code in excel to create a SP in oracle and it working fine.
But when I opened SP in oracle it showing entire code in single line. I have tried known ways to give line breaks but nothing works.
My actual VB code:
If sp_exist_chk_flag > 0 Then
Else
cmd_meta.CommandText = "create or replace PROCEDURE TEST_SP " & Chr(13) & _
"As" & Chr(13) & _
"REP DATA_REP.REP_ID%TYPE;" & Chr(13) & _
"SELECT REP_ID INTO REP FROM DATA_REP WHERE REP_NAME='xyz';" & Chr(13) & _
"COMMIT;" & Chr(13) & _
"END;"
cmd_meta.Execute
MsgBox "SP Created"
End If
In Oracle I can see SP is created as below
create or replace PROCEDURE TEST_SP As REP DATA_REP.REP_ID%TYPE; SELECT REP_ID INTO REP FROM DATA_REP WHERE REP_NAME='xyz'; COMMIT; END;
My actual SP is too long, so my vb code making it very long line.
Please help me on this with VB code or oracle command to look like an actual SP with proper line breaks in oracle.
Not sure if it will make a difference, but try using the vbCrLf constant instead of Chr(13).
If sp_exist_chk_flag > 0 Then
Else
cmd_meta.CommandText = "create or replace PROCEDURE TEST_SP " & vbCrLf & _
"As" & vbCrLf & _
"REP DATA_REP.REP_ID%TYPE;" & vbCrLf & _
"SELECT REP_ID INTO REP FROM DATA_REP WHERE REP_NAME='xyz';" & vbCrLf & _
"COMMIT;" & vbCrLf & _
"END;"
cmd_meta.Execute
MsgBox "SP Created"
End If

Resources