如何使用宏将mpp文件中的数据复制到Excel
我是宏新手。我想编写一个宏,以使用 Excel 将 MPP 列中的特定数据复制到另一个宏。
我找到了一个代码,可以将数据从一个 Excel 复制到另一个 Excel。请帮助
Option Explicit
Sub CopytoPS()
Dim sfil As String
Dim owbk As Workbook
Dim sPath As String
sPath = "C:\Users\HYMC\Excel\Test\" 'Change the file path for your purposes
sfil = Dir(sPath & "Management Report PS.xls")
Range("A2:I22").Copy
Set owbk = Workbooks.Open(sPath & sfil)
owbk.Sheets("Sales Data").Range("B65536").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
owbk.Close True 'Save opened workbook and close
sfil = Dir
End Sub
我想将 MPP 中的某些列复制到 Excel 中的一组列。我还希望用户只提供目标文件路径、源文件、源单元格要复制的单元格和目标单元格
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在 Excel 中使用 MPP 文件,请打开 VBA 编辑器并单击“工具”菜单上的“引用”。在“可用引用”列表中,单击以选中“Microsoft Project xx.xx 对象库”复选框。如果未列出 Microsoft Project 9.0 对象库,请单击“浏览”找到 MsprjXX.olb 文件,该文件位于安装 Microsoft Project 的文件夹中。默认位置是 C:\Program Files\Microsoft Office\Office。单击“确定”关闭“引用”对话框。然后使用此代码。
由于您没有提到要复制的内容以及确切的位置,因此我将为您提供一个非常基本的代码,您可以使用它来进行操作。
你可以访问此链接,这是一个很好的开始。但最终,这完全取决于您练习的程度:)
主题:记录和使用 Excel 宏
链接:http://office.microsoft.com/en-us/excel-help/record-and-use-excel-macros-HA001054837.aspx
有关宏的更多信息:
http://www.excel-vba.com/
http://www.excel-vba-easy.com/
http ://www.mrexcel.com/articles.shtml
To work with MPP file in Excel, Open the VBA Editor and click References on the Tools menu. In the Available References list, click to select the Microsoft Project xx.xx Object Library check box. If the Microsoft Project 9.0 Object Library is not listed, click Browse to locate the MsprjXX.olb file, which is in the folder where you have Microsoft Project installed. The default location is C:\Program Files\Microsoft Office\Office. Click OK to close the References dialog box. Then Use this code.
Since you have not mentioned what you want to copy and where exactly, i will give you a very basic code which you can then work on.
You can visit this link which is a good start. But ultimately, it all depends on how much you practice :)
Topic: Record and use Excel macros
Link: http://office.microsoft.com/en-us/excel-help/record-and-use-excel-macros-HA001054837.aspx
More On Macros:
http://www.excel-vba.com/
http://www.excel-vba-easy.com/
http://www.mrexcel.com/articles.shtml