A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Deleting Define Names



 
 
Thread Tools Display Modes
  #1  
Old September 18th, 2009, 10:45 PM posted to microsoft.public.access.forms
Souny
external usenet poster
 
Posts: 7
Default Deleting Define Names

Hello all,

I have define names in my Excel file. Of the define names that I have,
there are particular three define names that I want to delete using the code.
The code that I use is as followed:

for each dName in activeworkbook.names
if dName = "Sheet1!DefineName1" or dName="Sheet1!DefineName2" or
dName="'Sheet 2'!DefineName3" then
dName.delete
end if
next dName

Somehow, the above code is not working and is not deleting those define
names. The above code is a portion of my entire code.

Please help.

Thanks.
  #2  
Old September 18th, 2009, 10:51 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Deleting Define Names

This newsgroup is for questions about Access, the database product that's
part of Office Professional.

If you're using Access to automate Excel, the line of code

for each dName in activeworkbook.names

is invalid, since Access knows nothing about ActiveWorkbook: you need to
refer to the current instance of Excel for that to be meaningful to Access.

If you're using Excel, you'd be best off reposting to a newsgroup related to
Excel.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Souny" wrote in message
...
Hello all,

I have define names in my Excel file. Of the define names that I have,
there are particular three define names that I want to delete using the
code.
The code that I use is as followed:

for each dName in activeworkbook.names
if dName = "Sheet1!DefineName1" or dName="Sheet1!DefineName2" or
dName="'Sheet 2'!DefineName3" then
dName.delete
end if
next dName

Somehow, the above code is not working and is not deleting those define
names. The above code is a portion of my entire code.

Please help.

Thanks.



  #3  
Old September 18th, 2009, 11:01 PM posted to microsoft.public.access.forms
Souny
external usenet poster
 
Posts: 7
Default Deleting Define Names

Doug,

Sorry! I posted to a wrong area. It is for Excel.

Thanks.

"Douglas J. Steele" wrote:

This newsgroup is for questions about Access, the database product that's
part of Office Professional.

If you're using Access to automate Excel, the line of code

for each dName in activeworkbook.names

is invalid, since Access knows nothing about ActiveWorkbook: you need to
refer to the current instance of Excel for that to be meaningful to Access.

If you're using Excel, you'd be best off reposting to a newsgroup related to
Excel.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Souny" wrote in message
...
Hello all,

I have define names in my Excel file. Of the define names that I have,
there are particular three define names that I want to delete using the
code.
The code that I use is as followed:

for each dName in activeworkbook.names
if dName = "Sheet1!DefineName1" or dName="Sheet1!DefineName2" or
dName="'Sheet 2'!DefineName3" then
dName.delete
end if
next dName

Somehow, the above code is not working and is not deleting those define
names. The above code is a portion of my entire code.

Please help.

Thanks.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


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