LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default VBA question - getting name of workbook

Or even:

Dim WkbkA as workbook
Dim WkbkB as workbook

set wkbkA = activeworkbook

set wkbkB = Workbooks.open(filename:="filepath/FileB.xls")

wkbkA.activate

===
But you don't usually need to select/activate stuff to work with it.

maybe just things like:

with wkbkA.worksheets("sheet1")
.range("a1").value = "Hi there!"
end with



Paulw2k wrote:

Hi Ahliaks,

Your last premise is wrong. FA holds the value "FileA.xls", FB holds the
value "FileB.xls.
Also avoid declaring variables as variant if possible. Here the file names
are just text so use String.

Dim FA as String
Dim FB as String

FA = ActiveWorkbook.Name
Workbooks.open "filepath/FileB.xls"
FB =ActiveWorkbook.Name

To get hold of "FileA.xls" again
Workbooks(FA).Activate
......

To return to "FileB.xls"
Workbooks(FB).Activate

Hope that helps

Paul

"ajliaks " wrote in message
...
hey!

I have this question:

I open workbook "File A" and save its name like

Dim FA as VAriant
FA = ActiveWorkbook.name

Now I open Workbook "File B" and save its name like:

Dim FB as Variant
FB = ActiveWorkbook.name

The problem is that FA now takes the same value of FB, and I need to
use the first value!

What can I do?

Thanks.


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


--

Dave Peterson



 
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
Workbook Question Renee Excel Discussion (Misc queries) 2 March 12th 10 06:45 PM
Workbook question... Maurice Excel Discussion (Misc queries) 1 July 21st 09 12:03 AM
workbook question Jackie Excel Discussion (Misc queries) 9 August 13th 06 09:25 PM
Workbook Name question Stuart[_5_] Excel Programming 3 April 10th 04 07:35 PM
Question for Experts: Opening workbook with workbook references Chris Excel Programming 0 September 11th 03 07:05 PM


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