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

Hello,
I wonder why the following Excel VBA code does not work.

Sub test()
Dim myBook As Workbook
myBook = ActiveWorkbook
Debug.Print "the book name is" & myBook.Name
End Sub

Is it not possible to assign the reference to the workbook to a variable?
Thanks for answers Phil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Excel VBA basics

Hi,
Try


.......
Set myBook = ActiveWorkbook
........


Kind Regards.
--
Haldun Alay
"Philipp" , haber iletisinde sunlari ...
Hello,
I wonder why the following Excel VBA code does not work.

Sub test()
Dim myBook As Workbook
myBook = ActiveWorkbook
Debug.Print "the book name is" & myBook.Name
End Sub

Is it not possible to assign the reference to the workbook to a variable?
Thanks for answers Phil
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Excel VBA basics

Hi,

You need to use the Set command as it is an object variable.

Set myBook = ActiveWorkbook

Cheers
Andy

Philipp wrote:

Hello,
I wonder why the following Excel VBA code does not work.

Sub test()
Dim myBook As Workbook
myBook = ActiveWorkbook
Debug.Print "the book name is" & myBook.Name
End Sub

Is it not possible to assign the reference to the workbook to a variable?
Thanks for answers Phil


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Excel VBA basics

Haldun Alay wrote:

Hi,
Try


......
Set myBook = ActiveWorkbook
.......


OK that worked. Thank you for your prompt answers. Phil
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
Back to basics of excel 2003 driller Excel Worksheet Functions 4 April 28th 08 02:20 PM
Excel Forms: The basics please Wibs Excel Discussion (Misc queries) 2 March 14th 06 03:28 PM
Hi I'm New and need help with Excel Basics abi Excel Discussion (Misc queries) 10 November 23rd 05 07:25 PM
Excel Basics gallegos1580 Excel Discussion (Misc queries) 2 January 7th 05 06:45 PM
Transfering Acces Tabel to Excel with Visual Basics Syrus the Virus[_3_] Excel Programming 1 January 10th 04 12:23 AM


All times are GMT +1. The time now is 01:27 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"