Home > Software engineering >  [for] VBA ace to give advice or comments please! About to delete a worksheet after code program inte
[for] VBA ace to give advice or comments please! About to delete a worksheet after code program inte

Time:10-11

Copied from other workbook to the workbook in a table with code (the workbook engineering have a password, the password, I don't know, but I need to copy the data in this table), want to use vba to delete this code after copying data, the result after removing code program interrupt, consult, urgent urgent!!!!!
Private Sub CommandButton1_Click ()
Application. ScreenUpdating=False
Workbooks. Open Filename:="C: \ Documents and Settings \ Administrator \ \ desktop 1. XLS"
ActiveSheet. Copy after:=ThisWorkbook. Worksheets (1)
Workbooks (" 1. XLS "). The Close
Application. ScreenUpdating=True
Worksheets (2). Select
Dim I, j As Integer
Dim STR As String
STR=Worksheets (2). The CodeName
For I=1 To ActiveWorkbook. VBProject. VBComponents. Count
If ActiveWorkbook. VBProject. VBComponents (I). The Name=STR Then
J=I
The Exit For
End the If
Next I
ActiveWorkbook. VBProject. VBComponents (j) CodeModule. DeleteLines 1, _
ActiveWorkbook. VBProject. VBComponents (j) CodeModule. CountOfLines
Worksheets (2). The Columns (1). Select
Selection. Copy
Worksheets (1). Select
Worksheets (1). The Columns (1). Select
Selection. Paste
End Sub

May be because the copy of this table contains does not recognize the process and function of didn't appear such mistakes, how to solve this problem? Consult ace!!!!!!!!!!
After another: engineering code using API function, can see the code, but can only be removed manually code, password-protected using vba statement to delete the project, seems to just can see the code, cracking engineering rather than really delete the code

CodePudding user response:

Have a solution, in the beginning of the program and reference,

Refer to Microsoft Visual Basic For Application Extensibility
Dim VBC As VBComponent
. .

If not sure is this reference, you can check the original file of engineering object reference, and then a targeted in the copied file, at the beginning of the program to add the corresponding reference,
  •  Tags:  
  • VBA
  • Related