View Single Post
  #3   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.office.developer.vba,microsoft.public.word.tables,microsoft.public.word.vba.general
hornbecky83 hornbecky83 is offline
external usenet poster
 
Posts: 5
Default Show actual name of file path after you have renamed it

Thanks Cindy for all your help on the earlier posts I had! You've
really helped bring along my VBA code.

I realized what my problem was with this question. I needed to make an
array that would identify with the opened file. I pasted the code I
used at the end. I then used the arrayPath(i,j) and placed it into my
link field.

tablestring = "LINK Excel.Sheet.8" & " " & Chr(34) & arrayPath(i, j) &
Chr(34) & " " & Chr(34) & "Report Tables Delta
V!MissionTimelineDeltaVBudgetTable"" \a \f 4 \h"

Wdoc.Fields.Add Range:=rng, _
Text:=tablestring, PreserveFormatting:=True

This above code pasted it into my document, however, the path name did
not have two back slashes throughout it. It looked like this:
C:\Documents and Settings\Desktop\excel
templates\Mission.FY07Q1_Opt1FE1.xls, instead of this: C:\\Documents
and Settings\\Desktop\\excel templates\\Mission.FY07Q1_Opt1FE1.xls. The
single back slashes would not create a link with the table or allow me
to paste a table at all. Why does it matter if there are double back
slashes or not. I even tried my old code, prior to adding arrayPath,
and took out the double back slashes and it wouldn't work either.
Which tells me the issue must be with the double back slashes. Is
there a way to work around this? Or add double back slashes to my
privious arrayPath(i,j) method? I think this is my final issue with my
code, unless I can't get this figured out. I hope you can help me.
THank you.

Public Sub UseFileDialogOpen()

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Show

For lngCount = 1 To .SelectedItems.Count
MsgBox .SelectedItems(lngCount)
Next lngCount
i = 0
j = 0

For Each vrtSelectedItem In .SelectedItems

Workbooks.Open vrtSelectedItem

' loop through arrayOption to see if this option exists
For Each Ai In arrayOption
' see if we are at the end of the array - if so, add to the
array
Aoption = Worksheets("Report Tables Delta V").Range("B1")

If Ai = "" Then
arrayOption(i) = Aoption
Exit For 'added Option to array
End If

' check to see if we already have the option
If Ai = Aoption Then
Exit For 'already in array - we're done
End If

i = i + 1
Next Ai

' loop through arrayFltElem to see if this option exists
For Each Aj In arrayFltElem

FltElem = Worksheets("Report Tables Delta V").Range("D1")
' see if we are at the end of the array - if so, add to the
array
If Aj = "" Then
arrayFltElem(j) = FltElem
Exit For 'added Option to array
End If

' check to see if we already have the option
If Aj = FltElem Then
Exit For 'already in array - we're done
End If

j = j + 1
Next Aj
arrayPath(arrayOption(i), arrayFltElem(j)) = vrtSelectedItem
Next

End With
End Sub

Cindy M. wrote:
Hi Hornbecky83,

I renamed the C:\\ path to something like "Study Opt1FE2". But the
link will not work when C:\\...is replaced with Study Opt1FE2.

Word requires a "real path", that means a drive or network server
designation, followed by a valid path. "Study Opt1FE2" is not a valid
drive or server name, so you don't have a valid path. A LINK field
does not support a relative path; the path information must be a full
path.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)