Notices
Non Scooby Related Anything Non-Scooby related

VB (for excel) question

Thread Tools
 
Search this Thread
 
Old 22 November 2001, 01:16 PM
  #1  
airhead
Scooby Regular
Thread Starter
 
airhead's Avatar
 
Join Date: Oct 2000
Posts: 184
Likes: 0
Received 0 Likes on 0 Posts
Cool

very easy, as ever.

1) I need to capture the excel tab name in a certain macro. I have tried stuff like..
x = sheets("sheet1").name
and other stuff, but nothing works.
What is the correct command , please.

2) I would like to capture the (approx) excel file size, that one can see under File, Properties, General.
What is the correct command for this too, please.

airhead
Old 22 November 2001, 04:55 PM
  #2  
MattN
Scooby Regular
 
MattN's Avatar
 
Join Date: Nov 2000
Posts: 2,174
Likes: 0
Received 0 Likes on 0 Posts
Post

sheets("sheet1").select

that will select it - not sure what you mean by capture?
Old 22 November 2001, 05:10 PM
  #3  
Crispin
Scooby Regular
 
Crispin's Avatar
 
Join Date: Jan 2001
Posts: 534
Likes: 0
Received 0 Likes on 0 Posts
Post

Code:
    Dim exApp As New Excel.Application
    Dim sheetName$
    exApp.Workbooks.Open sFname
    sheetName = exApp.Workbooks(1).Worksheets(1).Name
hope that helps....
Old 22 November 2001, 08:07 PM
  #4  
airhead
Scooby Regular
Thread Starter
 
airhead's Avatar
 
Join Date: Oct 2000
Posts: 184
Likes: 0
Received 0 Likes on 0 Posts
Cool

just tried..
x = ActiveSheet.Name
..which works, but I thought I tried that at work, oh well.

still wouldn't mind the answer to the memory question if anyone knows.


When I said 'capture', I just want to let the variable (eg var x) equal the desired 'value/name', so that I can do something with the 'captured' value/name.
I'm just creating a 'lazy mans macro' that records info from large excel files (25-30mb, yes 3 of them) and pastes into a new workbook. When you have 200 records, the tab name helps id problems. It certainly beats recording the info by hand, or constantly toggling between sheets !

airhead

[Edited by airhead - 11/22/2001 8:20:56 PM]
Old 23 November 2001, 08:45 AM
  #5  
Martingb
Scooby Regular
 
Martingb's Avatar
 
Join Date: Oct 2001
Posts: 65
Likes: 0
Received 0 Likes on 0 Posts
Post

Airhead,

In reply to your second question, use the command FILELEN(pathname).
This returns a long amount in bytes of the file.

e.g.
Dim lFileLength as long
lFileLength = FILELEN(c:\winnt\win.ini)

Martin.
Old 23 November 2001, 10:31 AM
  #6  
Crispin
Scooby Regular
 
Crispin's Avatar
 
Join Date: Jan 2001
Posts: 534
Likes: 0
Received 0 Likes on 0 Posts
Post

My code works because I used it a couple o days ago to import stuff from an excel sheet.....

sheetName = exApp.Workbooks(1).Worksheets(1).Name


the sheet number is in the Worksheets collection......you just have to iterate this collection and get the name of the sheet you want.....

if you want a sample application lemme know....
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
leg200
Subaru Parts
5
07 October 2015 07:31 AM
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM



Quick Reply: VB (for excel) question



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