ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Public declare for Set.... (https://www.excelbanter.com/excel-programming/341506-public-declare-set.html)

zapatista66[_17_]

Public declare for Set....
 

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

--
zapatista6

-----------------------------------------------------------------------
zapatista66's Profile: http://www.excelforum.com/member.php...fo&userid=1195
View this thread: http://www.excelforum.com/showthread.php?threadid=47192


Jim Thomlinson[_4_]

Public declare for Set....
 
Why not place it into the on open event of the ThisWorkbook module...? Then
the varaibles will be initialized when the book opens...
--
HTH...

Jim Thomlinson


"zapatista66" wrote:


Hi, I have to use many workbooks in my program and I want to set the
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 Sub


--
zapatista66


------------------------------------------------------------------------
zapatista66's Profile: http://www.excelforum.com/member.php...o&userid=11956
View this thread: http://www.excelforum.com/showthread...hreadid=471920



zapatista66[_18_]

Public declare for Set....
 

I will try again, but I did it and the module didn't recognise wbBook1
as "Repair_Follow_up.xls".

thanks,


--
zapatista66


------------------------------------------------------------------------
zapatista66's Profile: http://www.excelforum.com/member.php...o&userid=11956
View this thread: http://www.excelforum.com/showthread...hreadid=471920



All times are GMT +1. The time now is 12:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com