如何在Publisher VBA中更新OLEObject的源文件路径

时间:2019-04-23 14:20:01

标签: vba publisher ms-publisher

发布商VBA

如何为Publisher中的所有OLEObject重新建立源文件。复制了发布者文件和源文件,并在网络上将其提供给我。但是,链接都断开了。 OLEOjbects的范围从 Excel 文件。

这是我到目前为止尝试过的操作,但是由于.SourceFullName是只读的,因此无法正常工作。

有没有一种方法可以实际分配新路径?

Private Sub UpdateObjectPath()

  'get source file
  Dim dlgOpen As FileDialog
  Dim sourceFile As String

  Set dlgOpen = Application.FileDialog(Type:=msoFileDialogOpen)
  If dlgOpen.Show = -1 Then
    sourceFile = dlgOpen.SelectedItems(1)
  Else
    Exit Sub
  End If

  'update links
  Dim shp As Shape
  Dim shpPage As Page

  For Each shpPage In ActiveDocument.Pages
    For Each shp In ActiveDocument.Pages(shpPage.PageIndex).Shapes
        If shp.Type = pbLinkedOLEObject Then
            'this does not work
            shp.LinkFormat.SourceFullName = sourceFile
        End If
    Next
  Next

End Sub

注意:我在菜单选项中都找不到可以更改链接位置的地方。也许我想念一些东西。

0 个答案:

没有答案