Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Applying a Workbook's Names to Another Workbook

I am trying to write a macro that gets a given workbooks' names and
applies them another workbooks links, which currently use letter/number
notation, to that master workbook. This is because Excel's own built-in
Apply Names functionality does not span workbooks as near as I can
tell.

Below is my attempt at a macro towards this end. It dies on the
"Cells.ApplyNames" line with a 1004 error. Can anyone provide some
advice?

Regards,

Matthew

Sub ApplyNamesFromMasterSheet()
Dim intNamesIdx As Integer
Dim oName As Name
Dim i As Long
Dim wkbk As Workbook
Dim sh As Worksheet
Dim aryNames As Names

Set aryNames = ActiveWorkbook.Names
Debug.Print aryNames.Count

With Application.FileSearch
.NewSearch
.LookIn = "\\my_server_name\my_directory\"
'.LookIn = ThisWorkbook.Path
.SearchSubFolders = False
.Filename = "my_workbook.xls"
.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Debug.Print "There were " & .FoundFiles.Count & _
" file(s) found. Please wait while updating."
Application.ScreenUpdating = False
For i = 1 To .FoundFiles.Count
If .FoundFiles(i) < ThisWorkbook.FullName Then
Workbooks.Open Filename:=.FoundFiles(i),
UpdateLinks:=0
Set wkbk = ActiveWorkbook
Debug.Print wkbk.FullName

For Each sh In wkbk.Worksheets
Debug.Print sh.Name
sh.Cells.ApplyNames Names:=aryNames
Next

'wkbk.Save
'wkbk.Close SaveChanges:=False
End If
Next i
Debug.Print "Update finished."
Application.ScreenUpdating = True
Else
Debug.Print "There were no files found."
End If
End With
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying users to site/names fgwiii[_2_] Excel Worksheet Functions 0 May 14th 09 07:38 PM
Applying range names to existing formulas in separate worksheets Marybeth Excel Discussion (Misc queries) 0 November 30th 06 02:06 PM
Applying same macro to all worksheets in workbook [email protected] Excel Discussion (Misc queries) 2 October 19th 05 11:25 PM
Applying names to ranges of cells for formulas MMH Excel Programming 10 July 13th 05 09:58 PM
Function to List an Excel Workbook's Sheet Names KymY Excel Discussion (Misc queries) 1 April 1st 05 10:47 AM


All times are GMT +1. The time now is 01:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"