1
リンクされたExcelファイルに関する問題がPowerpointプレゼンテーションにあります。 Excelファイルは、社内のすべてのPCのドライブ文字に割り当てられた外部サーバーでホストされています。問題は、Excelファイルへのリンクが、外部サーバー上にある場所にランダムに変更されることです。PPTがVBAを使用してパスファイルにリンクされたExcelファイルを変更する
私はマクロで回避策を置く:
Global fso As New FileSystemObject
Public Sub MaakKoppelingenRelatief()
Dim i As Integer
Dim sld As Slide, shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.Type = 3 Then
Dim path As String, fname As String
path = shp.LinkFormat.SourceFullName
fname = GetFilenameFromPath(path)
shp.LinkFormat.SourceFullName = fname
i = i + 1
End If
Next
Next
If i > 0 Then
MsgBox "Changed: " & CStr(i) & " Links", vbOK
Else
MsgBox "Couldn't find a linked file.", vbOK
End If
End Sub
Function GetFilenameFromPath(ByVal strPath As String) As String
Dim text1 As String
text1 = "N:\"
If Right$(strPath, 13) <> "\\tsclient\N\" And Len(strPath) > 0 Then
GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
End If
If Left$(strPath, 3) <> text1 And Len(strPath) > 0 Then
GetFilenameFromPath = text1 + strPath
End If
End Function
を私がいる問題は、コードのこの部分である:
If Left$(strPath, 3) <> text1 And Len(strPath) > 0 Then
GetFilenameFromPath = text1 + strPath
End If
それが唯一ながらそれは、私のパスにテキスト1を追加し続けますtext1が現在パスの最初の3文字にないときは、そうする必要があります。
誰かが私が間違ったことを理解するのに役立つことができますか?
ありがとうございます!
あなたが渡しているstrpathの値は何ですか?最初の3文字がtext1と同じでない場合はどうなりますか? – Spidey
strPathは、リンクされたExcelファイルのパスです。最初の3文字が同じでない場合は、Nを追加する必要があります。/ –
正確に何が起きているかを明確にするための例を挙げてください。 – Spidey