Public declare for Set....

  • Thread starter Thread starter zapatista66
  • Start date Start date
Z

zapatista66

Hi, I have to use many workbooks in my program and I want to set th
name of my workbook once. How can I do that ?

At this moment, I copy SetRefs in all modules and I run it at first
but is it possible to do that once.

thanks,

Public wbBook1 As Workbook
Public wbBook2 As Workbook
Public wbBook4 As Workbook
Public wbBook5 As Workbook

Public Sub SetRefs()
Dim ProjetActif As Variant, Projet As String
Set wbBook1 = Workbooks("Repair_follow_up.xls")
Set wbBook2 = Workbooks("Repairs.xls")
Set wbBook4 = Workbooks("Clients.xls")
wbBook1.Activate
Sheets("Feuille Calcul").Select
ProjetActif = Cells(3, 5)
Projet = ProjetActif & "_" & "Repair.xls"
Set wbBook5 = Workbooks(Projet)

End Su
 
Why not place it into the on open event of the ThisWorkbook module...? Then
the varaibles will be initialized when the book opens...
 
I will try again, but I did it and the module didn't recognise wbBook1
as "Repair_Follow_up.xls".

thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top