LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default Refering to Active Wbk from VB6

Hello,

I have found this code in a old posting that seems the right one to
get the a reference fron VB6 to the active Excel workbook. When
running it, i get "Sub or function not defined" that seems to refer to
CType . It could be that the code is written in VB.net. Could you help
with the right version for VB6 (if this is the problem)?

Sub Comm1()

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim myBookName As String

xlApp = CType((GetObject(, "Excel.Application")),
Excel.Application)
xlBook = CType(xlApp.ActiveWorkbook, Excel.Workbook)
myBookName = xlBook.Name
MsgBox (myBookName)

End Sub

 
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
Refering a cell Arun Kumar Saha Excel Worksheet Functions 2 June 18th 07 12:48 PM
Refering to another module Arne Hegefors Excel Programming 2 August 29th 06 08:15 AM
Refering to Cells madh83 Excel Worksheet Functions 3 July 19th 06 11:39 PM
refering to details in another sub Noemi Excel Programming 4 May 24th 06 03:49 AM
refering to a workbook name within vba DarrenWood[_5_] Excel Programming 4 July 1st 05 11:43 PM


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"