2017-01-11 9 views
0

を追加し、これが唯一の指定されたNCR番号(:\質\ NCRの[ここNCR番号]とそれはそれだ、すなわちR)へのパスを入れています。他の情報(PNと.xlsm)をリンクに引っ張ってこない理由を理解できません。助けてください!メール:何らかの理由でリンク

Dim Email_Subject, Email_Send_From, Email_Send_To, _ 
Email_Cc, Email_Bcc, Email_Body As String 
Dim Mail_Object, Mail_Single As Variant 
Dim PN As String 
Dim NCR As String 
Dim my_hyperlink As String 



PN = Worksheets("Sheet1").Range("C12").Value 
NCR = Worksheets("Sheet1").Range("I4").Value 

my_hyperlink = "R:\Quality\NCR's\" & NCR & " " & PN & ".xlsm" 

On Error GoTo debugs 
Set Mail_Object = CreateObject("Outlook.Application") 
Set Mail_Single = Mail_Object.CreateItem(0) 
With Mail_Single 
.Subject = "NCR: Part Failed Appearance" 
.To = "[email protected]" 
.cc = "[email protected]" 
.HTMLBody = PN & " has failed for appearance issues and requires a marketing disposition. This part has been cleared by engineering. Please see NCR number " & NCR & " in NCR Log for more details. See the Report <a href=" & my_hyperlink & ">Here</a>" 
.send 
End With 
+0

あなたはアンパサンドで始めることはできません。 – SJR

+0

あなたの文字列から最初の '&'を削除します。これは、 'Email_Body = PN&「外観上の問題のために失敗したとマーケティングの処分を必要としている。この部分は工学によってクリアされている。NCR番号を参照してください」&NCR&べきである「の詳細は、NCRログイン]を。」' –

答えて

0

であるべき開始時。

あなたが .HTMLBodyを使用するので、あなたはこれらを持っている行を置き換える必要が電子メールにこれを追加するために
dim my_hyperlink as string 
my_hyperlink = "R:\Quality\" & NCR & "'s\" & NCR & " " & PN & ".xlsm" 

(私が追加しました:ハイパーリンクの面では

は、次の操作を行うことができあなたの文の最後にハイパーリンク):効率性と可読性のために

Email_Body = PN & " has failed for appearance issues and requires a marketing disposition. This part has been cleared by engineering. Please see NCR number " & NCR & "in NCR Log for more details. The hyperlink is <a href=" & my_hyperlink & ">click here</a>" 

With Mail_Single 
.Subject = Email_Subject 
.To = Email_Send_To 
.cc = Email_Cc 
.BCC = Email_Bcc 
.HTMLBody = Email_Body 
.send 
End With 

、あなたがあなたのコードを変更することができます:

Sub emailmarketing() 

Dim Email_Subject, Email_Send_From, Email_Send_To, _ 
Email_Cc, Email_Bcc, Email_Body As String 
Dim Mail_Object, Mail_Single As Variant 
Dim PN As String 
Dim NCR As String 

PN = Worksheets("Sheet1").Range("C12").Value 
NCR = Worksheets("Sheet1").Range("I4").Value 

On Error GoTo debugs 
Set Mail_Object = CreateObject("Outlook.Application") 
Set Mail_Single = Mail_Object.CreateItem(0) 
With Mail_Single 
.Subject = "Non-Conformance Report: Part Failed Appearance" 
.To = "[email protected]" 
.cc = "[email protected]" 
.HTMLBody = PN & " has failed for appearance issues and requires a marketing disposition. This part has been cleared by engineering. Please see NCR number " & NCR & "in NCR Log for more details. The hyperlink is <a href=" & my_hyperlink & ">click here</a>" 
.send 
End With 
debugs: 
If Err.Description <> "" Then MsgBox Err.Description 

End Sub 

は、これが動作するかどうか、私に教えてください:)

+0

あなたは私を救済のために泣かせたかもしれないし、しなかったかもしれません。そんなにありがとうございました。 – ladymrt

+0

問題がなければ、それは答えとしてそれを受け入れてください、そうでなければ私に知らせてください:) –

+0

残念ながら、リンクはかなり完全に働いていません。私は自分の投稿を編集したので、今どこにいるのか分かります。なぜそれがすべてを取っていないのかについての任意のアイデア? – ladymrt

0

文字列連結演算子&(または+)には、それぞれの側にオペランドが必要です。あなたがアンパサンドを必要としないので

Email_Body = PN & " has failed for appearance issues and requires a marketing disposition. This part has been cleared by engineering. Please see NCR number " & NCR & "in NCR Log for more details." 

Email_Body = & PN & " has failed for appearance issues and requires a marketing disposition. This part has been cleared by engineering. Please see NCR number " & NCR & "in NCR Log for more details." 

は、次のように変更します。他の人が、ラインを示してきたように

Email_Body = & PN & " has failed for ap 

Email_Body = PN & " has failed for ap 
+0

これが働いていますこれまでのところ。今すぐハイパーリンクのために... – ladymrt

関連する問題