Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dont understand compile error


Hello everyone

I am trying to change the name of the open workbook to include th
textvalue of a cell. I am receiving a compile error when I add thi
line to my Before close code

ThisWorkbook.Name = "Defects " & Lists.Range("Q20").Value & ".xls"

The Compile Error states - Cant assign to read-only property.

.Name is highlighted

Where am I going wrong?

Kenny

Excel 9

--
N E Bod
-----------------------------------------------------------------------
N E Body's Profile: http://www.excelforum.com/member.php...fo&userid=1126
View this thread: http://www.excelforum.com/showthread.php?threadid=32059

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default dont understand compile error

The Name property of the Workbook property is the file name of
the xls file, and is a read only property. To change the name,
use the SaveAs method to save the file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"N E Body" wrote in
message ...

Hello everyone

I am trying to change the name of the open workbook to include
the
textvalue of a cell. I am receiving a compile error when I add
this
line to my Before close code

ThisWorkbook.Name = "Defects " & Lists.Range("Q20").Value &
".xls"

The Compile Error states - Cant assign to read-only property.

Name is highlighted

Where am I going wrong?

Kenny

Excel 97


--
N E Body
------------------------------------------------------------------------
N E Body's Profile:
http://www.excelforum.com/member.php...o&userid=11263
View this thread:
http://www.excelforum.com/showthread...hreadid=320594



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dont understand compile error


Sorry Chip I think it must be Friday afternoon syndrome but I cannot ge
my head round this one!

I tried changing it to ThisWorkbook.SaveAs and ActiveWorkbook.SaveA
but still get various errors.

Kenn

--
N E Bod
-----------------------------------------------------------------------
N E Body's Profile: http://www.excelforum.com/member.php...fo&userid=1126
View this thread: http://www.excelforum.com/showthread.php?threadid=32059

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default dont understand compile error

Post the code you are using with the SaveAs method, and describe
in detail the errors you are getting.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"N E Body" wrote in
message ...

Sorry Chip I think it must be Friday afternoon syndrome but I
cannot get
my head round this one!

I tried changing it to ThisWorkbook.SaveAs and
ActiveWorkbook.SaveAs
but still get various errors.

Kenny


--
N E Body
------------------------------------------------------------------------
N E Body's Profile:
http://www.excelforum.com/member.php...o&userid=11263
View this thread:
http://www.excelforum.com/showthread...hreadid=320594



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default dont understand compile error

You can't change the name of a workbook by changing the .Name property.

The .Name property is read-only. It is set to the filename when you save
the file. If you want to change the workbook name, you need to save the
file under that name, e.g..

ThisWorkbook.SaveAs FileName:="Defects " & Lists.Range("Q20").Value

This will save the file in the current directory. See SaveAs in VBA Help
for more.


In article ,
N E Body wrote:

Sorry Chip I think it must be Friday afternoon syndrome but I cannot get
my head round this one!

I tried changing it to ThisWorkbook.SaveAs and ActiveWorkbook.SaveAs
but still get various errors.

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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
Formula error, don't understand why... duugg Excel Discussion (Misc queries) 2 April 12th 06 06:52 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
I dont understand.... TOM Excel Programming 4 July 8th 04 02:49 PM


All times are GMT +1. The time now is 06:35 AM.

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

About Us

"It's about Microsoft Excel"