Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Workbook name is read only property?

The following code takes and existing worksheet, transposes the sheet,
then creates a separate workbook for each of the columns in the
transposed worksheet. I want to name each workbook from the
corresponding column header, but XL gives me a compile error that the
workbook name is a read-only property? Why?

Option Explicit
Sub Transpose2NewSht()
Dim wbCty As Workbook
Dim sNew As String
Dim lCurCol As Long
Dim wsSource As Worksheet
Dim wsTranspose As Worksheet
Dim sCty As String
Dim lStrDif As Long

Set wsSource = ActiveSheet

lCurCol = 2

wsSource.Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Copy
Sheets.Add.Activate
Set wsTranspose = ActiveSheet
wsTranspose.Name = "Transpose"

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

Do Until wsTranspose.Cells(1, lCurCol) = ""

sCty = wsTranspose.Cells(1, lCurCol)
lStrDif = Len(sCty) - 4
sCty = Right(sCty, Len(sCty) - lStrDif)

Range("A1:A4").Select
'Application.CutCopyMode = False
Selection.Copy
Workbooks.Add.Activate
Set wbCty = ActiveWorkbook
wbCty.Name = sCty <----- READ ONLY PROPERTY

Any suggestions?
Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Workbook name is read only property?

Yuo can't change the name of a file when it is opend. You Excel file is
opened therefore you can't change the name. Use Saveas to save the file,
then the name will automatically change.

"davegb" wrote:

The following code takes and existing worksheet, transposes the sheet,
then creates a separate workbook for each of the columns in the
transposed worksheet. I want to name each workbook from the
corresponding column header, but XL gives me a compile error that the
workbook name is a read-only property? Why?

Option Explicit
Sub Transpose2NewSht()
Dim wbCty As Workbook
Dim sNew As String
Dim lCurCol As Long
Dim wsSource As Worksheet
Dim wsTranspose As Worksheet
Dim sCty As String
Dim lStrDif As Long

Set wsSource = ActiveSheet

lCurCol = 2

wsSource.Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Copy
Sheets.Add.Activate
Set wsTranspose = ActiveSheet
wsTranspose.Name = "Transpose"

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

Do Until wsTranspose.Cells(1, lCurCol) = ""

sCty = wsTranspose.Cells(1, lCurCol)
lStrDif = Len(sCty) - 4
sCty = Right(sCty, Len(sCty) - lStrDif)

Range("A1:A4").Select
'Application.CutCopyMode = False
Selection.Copy
Workbooks.Add.Activate
Set wbCty = ActiveWorkbook
wbCty.Name = sCty <----- READ ONLY PROPERTY

Any suggestions?
Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Workbook name is read only property?

The workbook name is the file name and ultimately that is controlled by the
operating system. What you need to do is to save the file using the new name.

wbCty.SaveAs FileName:= thisworkbook.path & "\" & sCity
--
HTH...

Jim Thomlinson


"davegb" wrote:

The following code takes and existing worksheet, transposes the sheet,
then creates a separate workbook for each of the columns in the
transposed worksheet. I want to name each workbook from the
corresponding column header, but XL gives me a compile error that the
workbook name is a read-only property? Why?

Option Explicit
Sub Transpose2NewSht()
Dim wbCty As Workbook
Dim sNew As String
Dim lCurCol As Long
Dim wsSource As Worksheet
Dim wsTranspose As Worksheet
Dim sCty As String
Dim lStrDif As Long

Set wsSource = ActiveSheet

lCurCol = 2

wsSource.Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Copy
Sheets.Add.Activate
Set wsTranspose = ActiveSheet
wsTranspose.Name = "Transpose"

Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True

Do Until wsTranspose.Cells(1, lCurCol) = ""

sCty = wsTranspose.Cells(1, lCurCol)
lStrDif = Len(sCty) - 4
sCty = Right(sCty, Len(sCty) - lStrDif)

Range("A1:A4").Select
'Application.CutCopyMode = False
Selection.Copy
Workbooks.Add.Activate
Set wbCty = ActiveWorkbook
wbCty.Name = sCty <----- READ ONLY PROPERTY

Any suggestions?
Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Workbook name is read only property?

On Wed, 23 Apr 2008 08:43:04 -0700, Jim Thomlinson wrote:

The workbook name is the file name and ultimately that is controlled by the
operating system. What you need to do is to save the file using the new name.

wbCty.SaveAs FileName:= thisworkbook.path & "\" & sCity


Thanks, Jim, worked like a charm!
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
Excel 2007 Range.ServerActions Property displays read-only data SG Excel Programming 0 January 31st 08 03:33 PM
Reading back a Read/Write Property Gary''s Student Excel Programming 2 November 18th 07 10:06 AM
E-Mailing a File but property set as Read Only Sean Excel Programming 12 January 13th 07 06:53 PM
Network access to file - read only property AL Excel Discussion (Misc queries) 1 December 2nd 04 01:22 AM
Recommended Read-Only Property Tim Childs Excel Programming 2 September 24th 04 10:54 PM


All times are GMT +1. The time now is 08:20 PM.

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"