Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel SendMail Not working in XP Office 2003

I have an Excel Spreadsheet that contains a button. In the button there is a
macro that uses the Sendmail VB command. It works in Window 2000 Office
2000. Now, it does not work XP Office 2003. It goes into Debug mode and I
get the following error.

The VBProject of the Copy of Facility Request form.xls is either protected
or has no compoents.

Can it be fixed? Why do I get this error in XP Office 2003 and not in
Windows 2000 Office 2003?

Thanks for you help in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Excel SendMail Not working in XP Office 2003

Can you post the entire code which is behind the Button. Without it, it's
quite hard to tell.


"Dannyboy1001" wrote:

I have an Excel Spreadsheet that contains a button. In the button there is a
macro that uses the Sendmail VB command. It works in Window 2000 Office
2000. Now, it does not work XP Office 2003. It goes into Debug mode and I
get the following error.

The VBProject of the Copy of Facility Request form.xls is either protected
or has no compoents.

Can it be fixed? Why do I get this error in XP Office 2003 and not in
Windows 2000 Office 2003?

Thanks for you help in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel SendMail Not working in XP Office 2003

Here is the macro in the button:

Sub SendDocumentAsAttachment()

Dim wb As Workbook
Dim strdate As String
Dim fac, disemail As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
fac = wb.ActiveSheet.Range("B7").Value
disemail = wb.ActiveSheet.Range("Z7").Value

With wb
.SaveAs "Copy of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
If disemail = "" Then
.SendMail ", _
"Cloverleaf Interface Request for " & fac
Else
.SendMail ", disemail), _
"Cloverleaf Interface Request for " & fac
End If
RemoveAllMacros ActiveWorkbook
.Close True
End With
Application.ScreenUpdating = True
ActiveWorkbook.Close True

End Sub

Sub RemoveAllMacros(objDocument As Object)
' deletes all VBProject components from objDocument
' removes the code from built-in components that can't be deleted
' use like this: RemoveAllMacros ActiveWorkbook ' in Excel
' or like this: RemoveAllMacros ActiveWorkbookDocument ' in Word
' requires a reference to the
' Microsoft Visual Basic for Applications Extensibility library
Dim i As Long, l As Long
If objDocument Is Nothing Then Exit Sub
i = 0
On Error Resume Next
i = objDocument.VBProject.VBComponents.Count
On Error GoTo 0
If i < 1 Then ' no VBComponents or protected VBProject
MsgBox "The VBProject in " & objDocument.Name & _
" is protected or has no components!", _
vbInformation, "Remove All Macros"
Exit Sub
End If
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
On Error Resume Next
.VBComponents.Remove .VBComponents(i)
' delete the component
On Error GoTo 0
Next i
End With
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
l = 1
On Error Resume Next
l = .VBComponents(i).CodeModule.CountOfLines
.VBComponents(i).CodeModule.DeleteLines 1, l
' clear lines
On Error GoTo 0
Next i
End With
End Sub


"gocush" wrote:

Can you post the entire code which is behind the Button. Without it, it's
quite hard to tell.


"Dannyboy1001" wrote:

I have an Excel Spreadsheet that contains a button. In the button there is a
macro that uses the Sendmail VB command. It works in Window 2000 Office
2000. Now, it does not work XP Office 2003. It goes into Debug mode and I
get the following error.

The VBProject of the Copy of Facility Request form.xls is either protected
or has no compoents.

Can it be fixed? Why do I get this error in XP Office 2003 and not in
Windows 2000 Office 2003?

Thanks for you help in advance.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Excel SendMail Not working in XP Office 2003

A couple of things come to mind:
1. The message you are getting is not an error. It is part of the
RemoveAllMacros Sub that is included with your code. It says that either
there are no VBA components to remove, or that you have protected the VB Code
with a password. I would try looking at the vb code: Alt +F11. If it asks
for a password then you (or somebody) have protected the vb code, hence the
msg.
If this is the case, you can unprotect it or change the part of you code
that gives you the message.

2. In the first part of you code you are sending a copy of your worksheet
as email, THEN deleting the vb code. Usually, the vb code is removed BEFORE
sending the email in order to protect your code or if the recipient has no
need for it. Do you have some other reason for removing the code after
sending the email? If not then move the Remove..... line up before the
Sendmail line



"Dannyboy1001" wrote:

Here is the macro in the button:

Sub SendDocumentAsAttachment()

Dim wb As Workbook
Dim strdate As String
Dim fac, disemail As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
fac = wb.ActiveSheet.Range("B7").Value
disemail = wb.ActiveSheet.Range("Z7").Value

With wb
.SaveAs "Copy of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
If disemail = "" Then
.SendMail ", _
"Cloverleaf Interface Request for " & fac
Else
.SendMail ", disemail), _
"Cloverleaf Interface Request for " & fac
End If
RemoveAllMacros ActiveWorkbook
.Close True
End With
Application.ScreenUpdating = True
ActiveWorkbook.Close True

End Sub

Sub RemoveAllMacros(objDocument As Object)
' deletes all VBProject components from objDocument
' removes the code from built-in components that can't be deleted
' use like this: RemoveAllMacros ActiveWorkbook ' in Excel
' or like this: RemoveAllMacros ActiveWorkbookDocument ' in Word
' requires a reference to the
' Microsoft Visual Basic for Applications Extensibility library
Dim i As Long, l As Long
If objDocument Is Nothing Then Exit Sub
i = 0
On Error Resume Next
i = objDocument.VBProject.VBComponents.Count
On Error GoTo 0
If i < 1 Then ' no VBComponents or protected VBProject
MsgBox "The VBProject in " & objDocument.Name & _
" is protected or has no components!", _
vbInformation, "Remove All Macros"
Exit Sub
End If
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
On Error Resume Next
.VBComponents.Remove .VBComponents(i)
' delete the component
On Error GoTo 0
Next i
End With
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
l = 1
On Error Resume Next
l = .VBComponents(i).CodeModule.CountOfLines
.VBComponents(i).CodeModule.DeleteLines 1, l
' clear lines
On Error GoTo 0
Next i
End With
End Sub


"gocush" wrote:

Can you post the entire code which is behind the Button. Without it, it's
quite hard to tell.


"Dannyboy1001" wrote:

I have an Excel Spreadsheet that contains a button. In the button there is a
macro that uses the Sendmail VB command. It works in Window 2000 Office
2000. Now, it does not work XP Office 2003. It goes into Debug mode and I
get the following error.

The VBProject of the Copy of Facility Request form.xls is either protected
or has no compoents.

Can it be fixed? Why do I get this error in XP Office 2003 and not in
Windows 2000 Office 2003?

Thanks for you help in advance.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel SendMail Not working in XP Office 2003

Item 1 is not the issue, the VBA compoents when opened does not ask for a
password. I moved the RemoveAllMacros ActiveWorkbook statement before the IF
statement and I still get the same error. This code works without any issues
in Windows 2000/Office 2000. Can anyone tell me why this code is not working
in WIN XP/Office 2003?

"gocush" wrote:

A couple of things come to mind:
1. The message you are getting is not an error. It is part of the
RemoveAllMacros Sub that is included with your code. It says that either
there are no VBA components to remove, or that you have protected the VB Code
with a password. I would try looking at the vb code: Alt +F11. If it asks
for a password then you (or somebody) have protected the vb code, hence the
msg.
If this is the case, you can unprotect it or change the part of you code
that gives you the message.

2. In the first part of you code you are sending a copy of your worksheet
as email, THEN deleting the vb code. Usually, the vb code is removed BEFORE
sending the email in order to protect your code or if the recipient has no
need for it. Do you have some other reason for removing the code after
sending the email? If not then move the Remove..... line up before the
Sendmail line



"Dannyboy1001" wrote:

Here is the macro in the button:

Sub SendDocumentAsAttachment()

Dim wb As Workbook
Dim strdate As String
Dim fac, disemail As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
fac = wb.ActiveSheet.Range("B7").Value
disemail = wb.ActiveSheet.Range("Z7").Value

With wb
.SaveAs "Copy of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
If disemail = "" Then
.SendMail ", _
"Cloverleaf Interface Request for " & fac
Else
.SendMail ", disemail), _
"Cloverleaf Interface Request for " & fac
End If
RemoveAllMacros ActiveWorkbook
.Close True
End With
Application.ScreenUpdating = True
ActiveWorkbook.Close True

End Sub

Sub RemoveAllMacros(objDocument As Object)
' deletes all VBProject components from objDocument
' removes the code from built-in components that can't be deleted
' use like this: RemoveAllMacros ActiveWorkbook ' in Excel
' or like this: RemoveAllMacros ActiveWorkbookDocument ' in Word
' requires a reference to the
' Microsoft Visual Basic for Applications Extensibility library
Dim i As Long, l As Long
If objDocument Is Nothing Then Exit Sub
i = 0
On Error Resume Next
i = objDocument.VBProject.VBComponents.Count
On Error GoTo 0
If i < 1 Then ' no VBComponents or protected VBProject
MsgBox "The VBProject in " & objDocument.Name & _
" is protected or has no components!", _
vbInformation, "Remove All Macros"
Exit Sub
End If
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
On Error Resume Next
.VBComponents.Remove .VBComponents(i)
' delete the component
On Error GoTo 0
Next i
End With
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
l = 1
On Error Resume Next
l = .VBComponents(i).CodeModule.CountOfLines
.VBComponents(i).CodeModule.DeleteLines 1, l
' clear lines
On Error GoTo 0
Next i
End With
End Sub


"gocush" wrote:

Can you post the entire code which is behind the Button. Without it, it's
quite hard to tell.


"Dannyboy1001" wrote:

I have an Excel Spreadsheet that contains a button. In the button there is a
macro that uses the Sendmail VB command. It works in Window 2000 Office
2000. Now, it does not work XP Office 2003. It goes into Debug mode and I
get the following error.

The VBProject of the Copy of Facility Request form.xls is either protected
or has no compoents.

Can it be fixed? Why do I get this error in XP Office 2003 and not in
Windows 2000 Office 2003?

Thanks for you help in advance.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Excel SendMail Not working in XP Office 2003

oK. The message you are getting is dependent upon the following code line
from your Remove..... sub:

i = objDocument.VBProject.VBComponents.Count

could you put a breakpoint on this line, then run the code, step into this
one line then pass your cursor over the variable "i"

If "i" is less than 1 then you don't have any vb components in this new
workbook . You are trying to remove vb with this code. If none exists
then you will get this msg. To verify this, open the Visual Basic Editor,
Select the file that you are trying to email and see if there are any modules
or code behind the sheet objects or ThisWorkbook module.

Get back to us with what the vb component count is in the wbk you are
trying to email. Then we can see where to go from there.

"Dannyboy1001" wrote:

Item 1 is not the issue, the VBA compoents when opened does not ask for a
password. I moved the RemoveAllMacros ActiveWorkbook statement before the IF
statement and I still get the same error. This code works without any issues
in Windows 2000/Office 2000. Can anyone tell me why this code is not working
in WIN XP/Office 2003?

"gocush" wrote:

A couple of things come to mind:
1. The message you are getting is not an error. It is part of the
RemoveAllMacros Sub that is included with your code. It says that either
there are no VBA components to remove, or that you have protected the VB Code
with a password. I would try looking at the vb code: Alt +F11. If it asks
for a password then you (or somebody) have protected the vb code, hence the
msg.
If this is the case, you can unprotect it or change the part of you code
that gives you the message.

2. In the first part of you code you are sending a copy of your worksheet
as email, THEN deleting the vb code. Usually, the vb code is removed BEFORE
sending the email in order to protect your code or if the recipient has no
need for it. Do you have some other reason for removing the code after
sending the email? If not then move the Remove..... line up before the
Sendmail line



"Dannyboy1001" wrote:

Here is the macro in the button:

Sub SendDocumentAsAttachment()

Dim wb As Workbook
Dim strdate As String
Dim fac, disemail As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
fac = wb.ActiveSheet.Range("B7").Value
disemail = wb.ActiveSheet.Range("Z7").Value

With wb
.SaveAs "Copy of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
If disemail = "" Then
.SendMail ", _
"Cloverleaf Interface Request for " & fac
Else
.SendMail ", disemail), _
"Cloverleaf Interface Request for " & fac
End If
RemoveAllMacros ActiveWorkbook
.Close True
End With
Application.ScreenUpdating = True
ActiveWorkbook.Close True

End Sub

Sub RemoveAllMacros(objDocument As Object)
' deletes all VBProject components from objDocument
' removes the code from built-in components that can't be deleted
' use like this: RemoveAllMacros ActiveWorkbook ' in Excel
' or like this: RemoveAllMacros ActiveWorkbookDocument ' in Word
' requires a reference to the
' Microsoft Visual Basic for Applications Extensibility library
Dim i As Long, l As Long
If objDocument Is Nothing Then Exit Sub
i = 0
On Error Resume Next
i = objDocument.VBProject.VBComponents.Count
On Error GoTo 0
If i < 1 Then ' no VBComponents or protected VBProject
MsgBox "The VBProject in " & objDocument.Name & _
" is protected or has no components!", _
vbInformation, "Remove All Macros"
Exit Sub
End If
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
On Error Resume Next
.VBComponents.Remove .VBComponents(i)
' delete the component
On Error GoTo 0
Next i
End With
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
l = 1
On Error Resume Next
l = .VBComponents(i).CodeModule.CountOfLines
.VBComponents(i).CodeModule.DeleteLines 1, l
' clear lines
On Error GoTo 0
Next i
End With
End Sub


"gocush" wrote:

Can you post the entire code which is behind the Button. Without it, it's
quite hard to tell.


"Dannyboy1001" wrote:

I have an Excel Spreadsheet that contains a button. In the button there is a
macro that uses the Sendmail VB command. It works in Window 2000 Office
2000. Now, it does not work XP Office 2003. It goes into Debug mode and I
get the following error.

The VBProject of the Copy of Facility Request form.xls is either protected
or has no compoents.

Can it be fixed? Why do I get this error in XP Office 2003 and not in
Windows 2000 Office 2003?

Thanks for you help in advance.


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
Microsoft office excel 2003 has stopped working Veeshal Excel Discussion (Misc queries) 3 September 24th 09 07:30 PM
VISTA working with OFFICE 2003,2007 both or which? Robert Blass Excel Worksheet Functions 1 March 21st 09 07:15 PM
Office 2007 compatibility at office 2003 is not working for graphs Vinod[_2_] Excel Discussion (Misc queries) 0 December 4th 07 06:17 PM
How do i increase excel working memory in office 2003 Joseph Mwangi Excel Discussion (Misc queries) 1 October 8th 06 12:18 PM
Working with Office 2000 and Office 2003 - Urgent Suketu Excel Discussion (Misc queries) 0 April 20th 06 04:59 PM


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