Re: Macro to change linked object source file

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Andrew,

If all you need to do is to change *all* the filenames to the same new
filename, then a quick & dirty change to the code I referred you to should
do it.

The code has a Function named 'ParseOldField()', with the line
'SourceFileName = OldField'. Change that line to 'SourceFileName =
"test.xls"', using whatever the real filename is, minus the path.

Cheers

--
macropod
[MVP - Microsoft Word]


<andrewhharmon@xxxxxxxxx> wrote in message
news:1162331378.400619.307790@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hey,

Thanks for the help but that didn't seem to do it for me. That allowed
me to specify a folder which the links would be reset too. I need to
specify a new excel file name, more than likely in a folder with lots
of similar excel files. Anyway, it left all my links as invalid links.
Thanks anyway though.

-Andrew

macropod wrote:
Hi Andrew,

Check out the code in the document at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=261488
It may do what you want.

Cheers

--
macropod
[MVP - Microsoft Word]


<andrewhharmon@xxxxxxxxx> wrote in message
news:1162323999.025692.178010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have an word document with 84 inline linked objects from an excel
file. I need to be able to run a macro that will change the source
file
of all the linked objects. My solution was as follows but has two
issues.

Sub test()

Dim i As Integer
With ThisDocument
For i = 0 To .InlineShapes.Count
If .InlineShapes(i).Type = 2 Then
.InlineShapes(i).LinkFormat.SourceFullName = "C:\test.xls"
End If
Next i
End With

End Sub

Issues:

1. If the object i linked to is an excel chart, it incorporates the
original excel file name in the item section of the linked object. (if
you go to edit...links... its the item column). Changing the source
name does not change the item section, so charts give an error.

2. Four of my linked items are in a header. I have no idea how to
access those objects. when i do a ?thisdocument.inlineshapes.count, in
the immediate window, it returns 80.... but i have 84 linked objects.

I also tried the above code using fields instead of inlineshapes.. no
luck. I'm using Word 2002 and excel 2003

Any help would be gretaly appreciated. Thanks




.



Relevant Pages

  • textbook problems on H I/O (beginner)
    ... filename is given as an input to this function in csv1. ... Write the resultant array to the filename ... that is given as an input to this function in csv2 as a csv file. ... Read in an Excel file whose filename is ...
    (comp.soft-sys.matlab)
  • Re: gui/excel/array
    ... select an excel file. ... filesep is a function that returns the appropriate file seperator. ... FileName) ... To put the filename into the array, or to put the data into ...
    (comp.soft-sys.matlab)
  • Re: Open multiple excel spreadsheet from ppt VBA
    ... set wksheet1=XLApplication.workbooks.open(excel filename as ... But I don't know how to open another worksheet from the same excel file. ... workbook. ...
    (microsoft.public.powerpoint)
  • Re: Constant as network drive
    ... I try my best to not use the windows collection. ... I have an Excel file which needs to access another Excel file on a network. ... want to write the filename as a constant. ... refers to a file on my local drive, but if the constant refers to a network ...
    (microsoft.public.excel.programming)
  • Re: Link from Publisher to an Excel chart
    ... Create a linked object or embedded object from part of an existing file ... Open the file that contains the information you want to create a linked object ... On the Standard toolbar (toolbar: A bar with buttons and options that you use to ... Publisher will be automatically updated if I change the Excel file? ...
    (microsoft.public.excel.misc)