Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba SharePoint URL不工作的CreateItemFromTemplate_Vba_Excel - Fatal编程技术网

Vba SharePoint URL不工作的CreateItemFromTemplate

Vba SharePoint URL不工作的CreateItemFromTemplate,vba,excel,Vba,Excel,我试图使用VBA操作SharePoint网站上的电子邮件模板,但是,每当我使用该模板生成电子邮件时,我都会收到以下错误: “错误5:过程调用或参数无效” 这些模板被许多人使用并且经常更改,因此我的用户将无法在本地存储它们 请在下面查找我的当前代码: Function Gen_Email(filename As String) Dim olApp As Object Dim olMail As Object Const olFormatHTML As Long = 12345 Const olIm

我试图使用VBA操作SharePoint网站上的电子邮件模板,但是,每当我使用该模板生成电子邮件时,我都会收到以下错误:

“错误5:过程调用或参数无效”

这些模板被许多人使用并且经常更改,因此我的用户将无法在本地存储它们

请在下面查找我的当前代码:

Function Gen_Email(filename As String)
Dim olApp As Object
Dim olMail As Object
Const olFormatHTML As Long = 12345
Const olImportanceHigh As Long = 4

Set olApp = CreateObject("Outlook.Application")
'v----This causes the issue; "filename" points to a SharePoint site
Set olMail = olApp.CreateItemFromTemplate(filename)

bodyText = olMail.HTMLBody
subjectText = olMail.Subject

Set olMail = Nothing
Set olApp = Nothing

'<More code here>
End Function
函数genu\u电子邮件(文件名为字符串)
作为对象的Dim-olApp
将邮件作为对象
常量olFormatHTML,长度=12345
常量重要性高,长度=4
设置olApp=CreateObject(“Outlook.Application”)
"v",这就产生了问题,;“文件名”指向SharePoint网站
设置olMail=olApp.CreateItemFromTemplate(文件名)
bodyText=olMail.HTMLBody
subjectText=olMail.Subject
设置olMail=Nothing
设置olApp=Nothing
'
端函数

函数“CreateItemFromTemplate”只适用于本地文件,这就是发生上述问题的原因

上述问题的解决方案只需要两个更改:

  • 映射本地计算机上的SharePoint驱动器()

  • 将模板指向映射的驱动器。确保所有用户都映射相同的驱动器(例如,“F:\”


  • *.oft
    type的文件名是吗?@vityta我想是的,但再看一眼,它们都是*.msg。如果将模板放在本地,它能工作吗?@vityta模板在本地存储时能工作。