Visual studio 无法打开源文件 我试图打开一个用C++编写的项目,包括Excel自动化的MSO.DLL。但是,当我尝试导入MSO.dll时,我得到一个“无法打开源代码文件”错误。我已经将文件路径添加到附加的include目录(在Project->Properties->Configuration Properties->C/C++->General中)和链接器附加的include目录中

Visual studio 无法打开源文件 我试图打开一个用C++编写的项目,包括Excel自动化的MSO.DLL。但是,当我尝试导入MSO.dll时,我得到一个“无法打开源代码文件”错误。我已经将文件路径添加到附加的include目录(在Project->Properties->Configuration Properties->C/C++->General中)和链接器附加的include目录中,visual-studio,visual-c++,com,Visual Studio,Visual C++,Com,以下是我目前的代码: #pragma region Includes #include <stdio.h> #include <windows.h> //#include "Solution1.h" #pragma endregion #pragma region Import the type libraries #import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DL

以下是我目前的代码:

#pragma region Includes
#include <stdio.h>
#include <windows.h>
//#include "Solution1.h"
#pragma endregion


#pragma region Import the type libraries

#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL" \
    rename("RGB", "MSORGB") \
    rename("DocumentProperties", "MSODocumentProperties")

using namespace Office;
#pragma区域包括
#包括
#包括
//#包括“溶液1.h”
#布拉格端区
#pragma区域导入类型库
#导入“C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL”\
重命名(“RGB”、“MSORGB”)\
重命名(“DocumentProperties”、“MSODocumentProperties”)
使用名称空间办公室;

路径正确吗?此路径应根据Windows bitness和Office版本而有所不同。具体地说,在我的Win64计算机上,此文件位于

"C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\OFFICE16\\MSO.DLL"
以下是在
C:
驱动器上搜索此文件的快速方法。只需打开一个命令行并运行以下命令。复制和粘贴路径(甚至不需要转义),因为<代码> >中的路径包括和 >导入> <代码>指令不被当作C++字符串文字。
请不要发布文字图片,而是发布文字。未意识到,编辑了该帖子。
attrib /s c:\mso.dll