我在MAC上,所以即使我知道VBA,我也不知道如何在MAC上翻译它。我有这段代码,但是关于路径
我想要一个在此路径中加入特定文档(已经存在)的宏:
Path = "Z:\Reporting\" & ext3 & "\" & ext & " - " & ext2 & ".pdf"
(其中ext1 / 2/3是单元格值) 并通过Outlook MAC通过邮件发送。
这是我的代码:
Sub SaveMailRangeAsPDFIn2016()
Dim FilePathName As String
Dim strbody As String
FilePathName = ?
'Create the body text in the strbody string
strbody = "<FONT size=""3"" face=""Calibri"">"
strbody = strbody & "Hi there" & "<br>" & "<br>" & _
"This is line 1" & "<br>" & _
"This is line 2" & "<br>" & _
"This is line 3" & "<br>" & _
"This is line 4"
strbody = strbody & "</FONT>"
MacExcel2016WithMacOutlookPDF _
subject:="test", _
mailbody:=strbody, _
toaddress:="xxxxx@xxxx.xx", _
ccaddress:="", _
bccaddress:="", _
displaymail:="yes", _
accounttype:="", _
accountname:="", _
attachment:=FilePathName
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
具有功能:
Function MacExcel2016WithMacOutlookPDF(subject As String, mailbody As String, _
toaddress As String, ccaddress As String, _
bccaddress As String, displaymail As String, _
accounttype As String, accountname As String, _
attachment As String)
Dim ScriptStr As String, RunMyScript As String
ScriptStr = subject & ";" & mailbody & ";" & toaddress & ";" & ccaddress & ";" & _
bccaddress & ";" & displaymail & ";" & accounttype & ";" & _
accountname & ";" & attachment
'Call the RDBMacOutlook.scpt script file with the AppleScriptTask function
RunMyScript = AppleScriptTask("RDBMacOutlook.scpt", "CreateMailInOutlook", CStr(ScriptStr))
End Function
答案 0 :(得分:1)
MacOS / OSX使用与Windows "\"
不同的路径分隔符。
因此,如果您用这样的方式在VBA中对路径进行硬编码
Path = "Z:\Reporting\" & ext3 & "\" & ext & " - " & ext2 & ".pdf"
您可以检查操作系统并使用
If Application.OperatingSystem Like "*Mac*" Then
Path = "your mac path"
Else
Path = "Z:\Reporting\" & ext3 & "\" & ext & " - " & ext2 & ".pdf"
End If
请注意,Application.PathSeparator
返回操作系统使用的实际路径分隔符。