Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Declaring Variables

Probably v simple.....

What is the code for defining a variable to be the name of an exec
work book?

I have a macro within a template that needs to assign a variable to b
a name of the workbook created from the template.

Cheers

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Declaring Variables

Well if you want the variable to hold the NAME of the workbook:

Dim strWkBkNam As String
strWkBkNam = "Workbook.xls"

BUT, if you want the variable to be an object reference to the workboo
itself:

Dim WkBk1 As Workbook
Set WkBk1 = Workbooks("Workbook.xls")

Note the use of the "Set" keyword. This must always be used wit
object variables. - Piku

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Declaring Variables

or

strWkBkName = Activeworkbook.Name

or

strWkBkName = ThiwWorkbook.Name

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"pikus " wrote in message
...
Well if you want the variable to hold the NAME of the workbook:

Dim strWkBkNam As String
strWkBkNam = "Workbook.xls"

BUT, if you want the variable to be an object reference to the workbook
itself:

Dim WkBk1 As Workbook
Set WkBk1 = Workbooks("Workbook.xls")

Note the use of the "Set" keyword. This must always be used with
object variables. - Pikus


---
Message posted from http://www.ExcelForum.com/



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
Declaring variables freekrill Excel Discussion (Misc queries) 2 July 19th 06 06:36 AM
Declaring variables freekrill Excel Discussion (Misc queries) 0 July 18th 06 06:15 PM
Declaring Variables Robert[_16_] Excel Programming 2 November 20th 03 04:16 PM
DEclaring variables Pedro Excel Programming 2 November 13th 03 11:54 AM
Declaring Variables chris brunt Excel Programming 2 August 4th 03 02:02 PM


All times are GMT +1. The time now is 11:20 PM.

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"