ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Non Scooby Related (https://www.scoobynet.com/non-scooby-related-4/)
-   -   VB (for excel) question (https://www.scoobynet.com/non-scooby-related-4/55489-vb-for-excel-question.html)

airhead 22 November 2001 01:16 PM

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

MattN 22 November 2001 04:55 PM

sheets("sheet1").select

that will select it - not sure what you mean by capture?

Crispin 22 November 2001 05:10 PM

Code:

    Dim exApp As New Excel.Application
    Dim sheetName$
    exApp.Workbooks.Open sFname
    sheetName = exApp.Workbooks(1).Worksheets(1).Name

hope that helps....

airhead 22 November 2001 08:07 PM

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]

Martingb 23 November 2001 08:45 AM

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.

Crispin 23 November 2001 10:31 AM

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....


All times are GMT +1. The time now is 02:01 PM.


© 2024 MH Sub I, LLC dba Internet Brands