HOWTO:将OLE对象嵌入Excel并使用PowerShell将其与文件链接 [英] HOWTO: Embed an OLE Object into Excel and Link It with a File Using PowerShell
问题描述
你好,
我正在尝试使用PowerShell以编程方式将链接插入Excel工作表。
I am trying to programmatically insert links into the Excel worksheet using PowerShell.
我希望所有单元格都在要填充的工作表的特定列,每个列都包含一个链接到文件的对象。此对象可能是HYPERLINK对象,或者可能是连接到某个位置的Paint.Picture对象,最好是在文件系统上。
I would like all cells in a specific column of a worksheet to be populated each with an object that links to a file. This object might be a HYPERLINK object or, possibly an Paint.Picture object that links to some, location, preferably on a file system.
目前,我想 我可以 我可以;使用OLE嵌入。例如,要从
插入文件图标 C:\ WINDOWS \system32 \ imagesmage.dll DLL,我d do:
Currently, I thought I could use OLE Embedding. For example, to insert a file icon from the C:\WINDOWS\system32\imageres.dll DLL, I'd do:
$missing = [System.Type]::missing
$excel = New-Object -Com Excel.Application
$excel.visible = $True
$wb = $excel.Workbooks.Add($missing)
$ws = $wb.Worksheets.Item(1)
$oleObjects = $ws.OLEObjects($missing)
$FileIcon = $oleObjects.Add("Paint.Picture",$missing,$true,$True,"C:\WINDOWS\system32\imageres.dll",1,"",$missing,$missing,$missing)
但是,这只会插入一个图标。如何将图标链接到特定文件?如果那是不可能的,我怎么才能在单元格中插入一个文件位置的链接?
However, this only inserts an icon. How would I link the icon to a specific file? If that's not possible, how would I just insert a link to a file location in a cell?
我希望用户能够在点击图标时打开引用的文件或链接在特定单元格中。例如,我可以使用PDF文件类型图标来引用单元格中的用户手册。
I'd like the user to be able to open referenced file when clicking on an icon or link in a specific cell. For example, I could use the PDF file type icon to reference a User manual in a cell.
这可能吗?
提前谢谢。
这就是我们生活的世界这些是我们给予的双手......
Well this is the world we live in And these are the hands we're given...
推荐答案
嘿比尔,
为什么要移动主题?它与Excel有什么关系?它更多是关于使用PowerShell编写有关使用Excel的脚本!
Why did you move the topic? How is it relevant to Excel? It's more about scripting with PowerShell that about using Excel!
这篇关于HOWTO:将OLE对象嵌入Excel并使用PowerShell将其与文件链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!