Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mass update Excel file connection string

We have recently changed our SQL Database server and i was wondering if there would be a script or an easier method of updating all the Excel file connection strings?

It would of been alot easier if they used a connection file but unfortunately they were all set manually and we have about 600 reports...

Any help is much appreciated.

Thanks

Nick

like image 535
Nick Ower Avatar asked Jul 31 '12 01:07

Nick Ower


2 Answers

I wanted to do the exact same thing and came accross this tool called XLODCTool from here.

File link here.

Allos you to bulk change values inside of a connection string e.g.

DSN From SERVERA to SERVERB

like image 159
Matt Avatar answered Oct 07 '22 06:10

Matt


Yes you can... you make a program in c# or vb.net that loops throu all of your 600 documents and opens the documents and by using

    oModule = oBook.VBProject.VBComponents.Add(VBIDE.vbext_ComponentType.vbext_ct_StdModule)
    oModule.CodeModule.AddFromString(sCode)

and depending on your setup in the sCode variable you have a macro that loops through Excel.Connections or

    For Each wks In ActiveWorkbook.Worksheets
      For Each qt In wks.QueryTables
        With qt
          .Connection ="myconnstring" 
        End With
      Next qt
    Next wks
like image 22
Archlight Avatar answered Oct 07 '22 05:10

Archlight