From: BlairH on 4 Jun 2010 10:11 Can I set a variable to refer to a workbook, e.g.: Dim mywkbk as workbook mywkbk = activeworkbook that way if another workbook becomes active the mywkbk will refer to the original workbook. it just doesn't want to work for me. I can do this: Dim mywkbk as string mywkbk = activeworkbook.name then use workbooks(mywkbk) to refer to the workbook. any way to get the first method to work in XL 2003?
From: Jackpot on 4 Jun 2010 10:14 Use the Set statement which assigns an object reference to a variable or property. Dim mywkbk as workbook Set mywkbk = Activeworkbook Msgbox myWkbk.Name Msgbox myWkbk.Sheets.Count "BlairH" wrote: > Can I set a variable to refer to a workbook, e.g.: > > Dim mywkbk as workbook > > mywkbk = activeworkbook > > that way if another workbook becomes active the mywkbk will refer to the > original workbook. > > it just doesn't want to work for me. > > I can do this: > > Dim mywkbk as string > > mywkbk = activeworkbook.name > > then use workbooks(mywkbk) to refer to the workbook. > > any way to get the first method to work in XL 2003?
From: BlairH on 4 Jun 2010 10:26 Excellent. Thanks! "Jackpot" wrote: > Use the Set statement which assigns an object reference to a variable or > property. > > Dim mywkbk as workbook > Set mywkbk = Activeworkbook > Msgbox myWkbk.Name > Msgbox myWkbk.Sheets.Count >
|
Pages: 1 Prev: Date lies between Next: form not opening when started from command line |