សេកមាស បន្ទាយមានជ័យ
អាស័យដ្ឋានៈ ទីតាំងទី១ នៅទល់មុខសាលាសូភី ខាងជើងភ្លើងស្តុប៧០ម៉ែត្រ ក្រុងសិរីសោភ័ណ ខេត្តប.ជ ។
Tel: 012 89 52 53 / 098 353 555 | E-mail: Sekmeas_bmc@yahoo.com
សេកមាស សំរោង
អាស័យដ្ឋានៈ ទីតាំងទី២ នៅទល់មុខបឹងស្នោ ជាប់សាលាសំរោង ក្រុងសំរោង ខេត្តឧត្តរមានជ័យ ។
Tel: 012 700 599 / 088 8 001 001 | E-mail: Sekmeas_omc@yahoo.com
សេកមាស អន្លង់វែង
អាស័យដ្ឋានៈ ទីតាំងទី៣ នៅទល់មុខវិទ្យាល័យអន្លង់វែង ផ្លូវទៅព្រះវិហារ ស្រុកអន្លង់វែង ខេត្តឧត្តរមានជ័យ ។
Tel: 012 433 588 / 088 474 5555 | E-mail: Sekmeas_len@yahoo.com
ម្លប់បៃតង និង ពិភពតែម
អាស័យដ្ឋានៈ ផ្លូវលេខ ៣ ពីការាស់សាំងសូគីមិច ប្រហែល100ម៉ែត្រ ក្រុងសិរីសោភ័ណ ខេត្តបន្ទាយមានជ័យ ។
Tel: 065 5 600 500 / 088 888 38 48 / 016 733 622 (world sticker)
Wednesday, September 25, 2013
របៀបដំណើរការកម្មវិធីជាមួយ Administrator
OPTION ONE
"Run as administrator" using a Keyboard Shortcut
NOTE: This will allow you to temporarily run a program as an administrator once until you close it.
1. Press and hold Ctrl+Shift while opening the program.
2. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an Administrator.
NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.
OPTION TWO
"Run as administrator" using Context Menu of Program
NOTE: This will show you how to temporarily run a program as an administrator once until you close it.
1. Right click on the program's shortcut or an .EXE file, BAT file, CMD file, or MSI file, and click on Run as administrator. (see screenshot below)2. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an administrator.
NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.
OPTION THREE
"Run as administrator" from Pinned Program on Taskbar
NOTE: This will show you how to temporarily run a program pinned to the taskbar as an administrator once until you close it.
1. Right click on the icon of the pinned program on the taskbar to open it's Jump List. (see screenshot below)
2. In the Jump List, right click on the program's name, and click on Run as administrator. (see screenshot below)3. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an Administrator.
NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.
OPTION FOUR
"Run as administrator" from Start Menu Search Box
NOTE: This will show you how to temporarily run a program as an administrator once until you close it.
1. Type in the file name (ex: cmd) of the program that you want to run elevated. (see screenshot below)2. Do either step 3 or 4 below.
3. Press Ctrl+Shift+Enter to open the program (ex: cmd) elevated, and go to step 5 below.
OR
4. Do OPTION TWO as above to right click on the program (ex: cmd) in the search results at the top of the Start Menu, and click on Run as administrator. (see screenshot below step 1)
5. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an Administrator.
NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.
OPTION FIVE
"Run as administrator" using Compatibility Mode
NOTE: This will show you how to always have the program run as an administrator when you open it.
1. Right click on the program shortcut or program .exe file, then click on Properties, and on the Compatibility tab. (see screenshots below)
NOTE: If you are doing this while logged on as a standard user instead of an administrator, then you will need to also click on the Change settings for all users button and type in the administrator's password.2. To Always Run this Program as an Administrator
A) Check the Run this program as an administrator box, and click on OK. (see screenshots above)3. To Not Always Run this Program as an Administrator
A) Uncheck the Run this program as an administrator box, and click on OK. (see screenshots below step 1)4. Open the program.
5. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an administrator.
NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.
OPTION SIX
"Run as administrator" using Advanced Properties
NOTE: This will show you how to always have only this specific shortcut of the program run as an administrator when you open it, and not from any other shortcut or .exe of the program.
1. Right click on a shortcut that you want to run as administrator, and click on Properties.
2. Click on the Shortcut tab for a program shortcut, then cllick on the Advanced button. (see screenshot below)3. To Always Run this Specific Shortcut as an Administrator
A) Check the Run as administrator box, and click on OK. (see screenshot below)4. To Not Always Run this Specific Shortcut as an Administrator
A) Uncheck the Run as administrator box, and click on OK. (see screenshot above)5. Click on OK. (see screenshot below step 2)
6. Open the program.
7. If prompted by UAC, then click on Yes to apply permission to allow the program to run with full permission as an Administrator.
NOTE: If you are doing this is while logged in as standard user instead of an administrator, then you will need to provide the administrator's password before the program will run as administrator.
OPTION SEVEN
"Run as administrator" using an Elevated Shortcut
1. For how, see:How to Create a Elevated Program Shortcut without a UAC Prompt
OR
How to Create a Elevated Program Shortcut a Standard User is able to Run in Windows 7
OPTION EIGHT
"Run as administrator" Manually in Registry Editor
1. For how, use the RUNASADMIN value with the full path to the program's file in OPTION THREE here: How to Run a Program in Compatibility Mode in Windows 7
Note
Tuesday, September 24, 2013
ប្រើអ៊ីមែលជាមួយ MS Outlook 2010
បើក MS Outlook 2010
ចុច File =>
Add Account
ជ្រើសរើស Manually configure server settings or additional server type រួចចុច Next
ជ្រើសរើស Internet E-mail រួចចុច Next
រួចធ្វើការបញ្ចូលដូចខាងក្រោម
· ត្រង់ព័ត៌មាន User Information
Your Name: ឈ្មោះរបស់យើង
E-mail Address: ជាអ៊ីមែលរបស់យើង
· ត្រង់ព័ត៌មាន Sever Information
សូមបំពេញតាមអ៊ីមែលរបស់យើង
សម្រាប់ Yahoo
- Incoming mail server: pop.mail.yahoo.com
- Outgoing mail server (SMTP): smtp.mail.yahoo.com.
សម្រាប់ Mail
- Incoming mail server: pop.mail.com
- Outgoing mail server (SMTP): smtp.mail.com.
សម្រាប់ Gmail
- Incoming mail server: imap.gmail.com
- Outgoing mail server (SMTP): smtp.gmail.com.
សម្រាប់ Hotmail
- Incoming mail server: pop3.live.com
- Outgoing mail server (SMTP): smtp.live.com.
· ត្រង់ព័ត៌មាន Logon Information
User Name: ជាអ៊ីមែលរបស់យើង
Password: ជាលេខសម្ងាត់របស់អ៊ីមែលយើង
រួចចុចប៊ូតុង Mort Settings…
ចូលទៅកាន់ Outgoing Server
ជ្រើសរើស My outgoing server (SMTP) requires authentication
យក Log on using សូមបំពេញព័ត៌មានខាងក្រោម
User Name: ជាអ៊ីមែលរបស់យើង
Password: ជាលេខសម្ងាត់របស់អ៊ីមែលយើង
ជ្រើសរើស My outgoing server (SMTP) requires authentication
យក Log on using សូមបំពេញព័ត៌មានខាងក្រោម
User Name: ជាអ៊ីមែលរបស់យើង
Password: ជាលេខសម្ងាត់របស់អ៊ីមែលយើង
ចូលទៅកាន់ Advanced
ត្រូវកំណត់ Port ឲ្យស្របតាមអ៊ីមែលយើង
សម្រាប់ Yahool
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465
សម្រាប់ Mail
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465
សម្រាប់ Gmail
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465 StartTLS Port 587
សម្រាប់ Hotmail
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465 StartTLS Port 587
ជ្រើសរើស This sever requires an encrusted connection (SSL)
ត្រង់ Use the following type of encrusted connection: យក SSL
ត្រូវកំណត់ Port ឲ្យស្របតាមអ៊ីមែលយើង
សម្រាប់ Yahool
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465
សម្រាប់ Mail
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465
សម្រាប់ Gmail
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465 StartTLS Port 587
សម្រាប់ Hotmail
- Incoming mail server (POP3): SSL Port 995
- Outgoing mail server (SMTP): SSL Port 465 StartTLS Port 587
ជ្រើសរើស This sever requires an encrusted connection (SSL)
ត្រង់ Use the following type of encrusted connection: យក SSL
ត្រប់ Remove server after ……….. days ជ្រើសរើសយកចំនួនថ្ងៃ ដែលលុបចោល
ស្វែងយល់ពី Mail Server និង Mail Client
Mail Server គឺជាសេវាកម្មសម្រាប់ចាយចែក Email ទៅកាន់ម៉ាស៊ីនកូន (Client) សម្រាប់ធ្វើការប្រើប្រាស់ ។ Mail Server ត្រូវបានដំឡើងដោយ ប្រតិបត្តិការម៉ាស៊ីនមេ ដូចជា (Windows Server 2003, 2008, Ubuntu Server និងមានច្រើនទៀត) ។ Mail Server ឬក៏ត្រូវបានស្គាល់ថា Mail Transfer Agent គឺជាសេវាកម្មមួយ សម្រាប់គ្រប់គ្រងរាល់សំបុត្រទាំងឡាយ ដែលបានផ្ញើចេញ ឬទទួលបានពីអ៊ិនធើណេតមករក្សាទុកក្នុងម៉ាស៊ីនមេ រួចទើបបញ្ចូននូវទិន្នន័យនោះ ទៅកាន់អ្នកប្រើប្រាស់វិញ តាមកម្មវិធី Outlook Express, Thunderbird, Opera mail និង Evolution Email ជាដើម ។
រីឯ Mail Client មានតួនាទីសម្រាប់ទទួលសារ (សំបុត្រ) ដែលមានកម្មវិធីដូចជា Microsoft Outlook 2003/2007/2010, Mozilla Thunderbird, Eudora ។
Mail Server ត្រូវបានប្រើប្រាស់សេវាកម្ម ពីរ សម្រាប់គ្រប់គ្រង Mail
- POP3 មកពីពាក្យថា Post Office Protocol Version 3 ជាសេវាកម្មមួយ ដែលប្រើនូវ Protocol ប្រភេទ POP3 ដើម្បីទទួលយកសំបុត្រដែលបាន រក្សាទុកក្នុងម៉ាស៊ីន Mail Server មកអានហើយវាមាន Port ស្មើនឹង 110 ។
- SMTP មកពីពាក្យថា Simple Mail Transfer Protocol ជាសេវាកម្មមួយដែលប្រើនូវ Protocol ប្រភេទ SMTP សម្រាប់បញ្ជូនសំបុត្រទៅកាន់ Mail Server ឬក៏អ៊ិនធើណេត ហើយវាមាន Port ស្មើនឹង 25 ។ ហេតុអ្វីចាំបាច់បង្កើត Mail Server ?ការបង្កើត Mail Server គឺមានសារៈប្រយោជន៍ ដូចជា គ្រប់គ្រងម៉ាស៊ីនកូនទាំងអស់នៅក្នុងប្រព័ន្ធ Network អាំចផ្ញើអ៊ីម៉ែលទំនាក់ទំនងគ្នាទៅវិញទៅមក បានយ៉ាងងាយស្រួលទៀតផង ជាពិសេសទោះបីជាមិនមានអ៊ិនធើណេតក៏ដោយ ក៏អាចផ្ញើអ៊ីម៉ែលទៅកាន់មនុស្សដទៃទៀតនៅលើប្រព័ន្ធអ៊ិនធើណេតបានផងដែរ៕
ដំណើរការរបស់ Mail Server
Sunday, September 22, 2013
Saturday, September 21, 2013
រលឹកពេលជិតដល់កាលកំណត់នៅលើ Excel
MS Excel: Macro to warn when a record will expire within 31 days in Excel 2003/XP/2000/97
Question: We work with subcontractors who have insurance certificates that expire at various dates. We store these certificates and expiry dates in Microsoft Excel 2003/XP/2000/97.Is there a way in Excel to warn me when a particular certificate is about to expire?
Answer: There are several "events" available within an Excel spreadsheet where you can place VBA code. In your case, we want to place our code in the "Workbook_Open" event.
Let's take a look at an example.
Download Excel spreadsheet (as demonstrated below)
In our spreadsheet, there is a sheet called Sheet1. In column C, we store the expiry date for each insurance certificate.
When the Excel file is opened, the VBA code on the "Workbook_Open" event automatically runs to check the first 200 rows in this spreadsheet. Each row is checked to see if the certificate will expire in the next 31 days.
In our example, we've opened the file on Sept 1, 2003. In this case, we will get the following warning message:
The macro will generate one warning message for each certificate that will expiry within the next 31 days.
You can press Alt-F11 to view the VBA code.
Macro Code
The macro code looks like this:Private Sub Workbook_Open()
Dim LRow As Integer
Dim LResponse As Integer
Dim LName As String
Dim LDiff As Integer
Dim LDays As Integer
LRow = 2
'Warning - Number of days to check for expiration
LDays = 31
'Check the first 200 rows in column C
While LRow < 200
'Only check for expired certificate if value in column C is not blank
If Len(Sheets("Sheet1").Range("C" & LRow).Value) > 0 Then
LDiff = DateDiff("d", Date, Sheets("Sheet1").Range("C" & LRow).Value)
If (LDiff > 0) And (LDiff <= LDays) Then
'Get subcontractor name
LName = Sheets("Sheet1").Range("A" & LRow).Value
LResponse = MsgBox("The insurance certificate for " & LName & " will expire in " & LDiff & " days.", vbCritical, "Warning")
End If
End If
LRow = LRow + 1
Wend
End Sub
ដំណើការ Form ដោយស្វ័យប្រវត្តិ នៅលើ Excel
MS Excel: Automatically open a Form when spreadsheet is opened in Excel 2003/XP/2000/97
Question: In Microsoft Excel 2003/XP/2000/97, I have a form called UserForm1. How do I automatically open the form when the workbook is opened?Answer: There are several "events" available within an Excel spreadsheet where you can place VBA code. In your case, we want to open the form when the "Workbook_Open" event fires.
To do this, press Alt-F11 to go to the Visual Basic editor.
Then select ThisWorkbook in the left window. In the right window, select Workbook in the first drop-down and Open in the second drop down. Then enter the following VBA code:
Private Sub Workbook_Open()
UserForm1.Show
End Sub
Now when the spreadsheet is opened, the form called UserForm1 will automatically open.
របៀបបំលែងពីតំលៃលុយទៅជាអក្សរ
How to convert a numeric value into English words in Excel
បើកកម្មវិធី Excelរួចចុច Alt+F11 ដើម្បីបើក Visual Basic Editorចុច Insert ហើយយក Module ហើយ Copy កូដ ខាងក្រោមចូល
Code:
Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & " Dollars"
End Select
Select Case Cents
Case ""
Cents = " and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Cents
End Function
' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
Friday, September 20, 2013
ចុចពីដងលើ Cell ទទួលបានសញ្ញាជ្រើសរើស
បើកកម្មវិធី Excel
រួចចុច Alt+F11 ដើម្បីបើក Visual Basic Editor
ចុចជ្រើសរើស Sheet ណាមួយដែលចង់ប្រើរូបមន្តនេះ រួច Copy កូដ ខាងក្រោមដូច ចូល
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'******************************************************************************************
'* Copyright by Sekmeas.blogspot.com *
'******************************************************************************************
If Not Intersect(Target, Range("A2:A300")) Is Nothing Then ' You can Change the range here
Cancel = True
With Target
.Font.Name = "Wingdings"
.Font.Size = 12
.HorizontalAlignment = xlCenter
End With
If Target.Value = "þ" Then
Target.Value = "ý"
Else
Target.Value = "þ"
End If
End If
End Sub
'Copy Right © Sekmeas.blogspot.com All Rights Reserved
Thursday, September 19, 2013
បិទ cut copy paste និង Right Click នៅលើ Excel
ដោយចុច Alt+F11 ដើម្បីបើក Visual Basic Editor
ចុច ThisWorkbook រួច Copy កូដខាងក្រោមដូច
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
With Application
.CellDragAndDrop = True
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"
.OnKey "+{DEL}"
.OnKey "^{INSERT}"
.CutCopyMode = False
End With
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19) 'copy
Ctrl.Enabled = True
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21) ' Cut
Ctrl.Enabled = True
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=22) ' Paste
Ctrl.Enabled = True
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=755) ' Paste Special
Ctrl.Enabled = True
Next Ctrl
End Sub
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
Private Sub Workbook_Open()
On Error Resume Next
With Application
.CutCopyMode = False
.CellDragAndDrop = False
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
.OnKey "+{DEL}", ""
.OnKey "^{INSERT}", ""
End With
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19) ' Copy
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21) ' Cut
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=22) ' Paste
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=755) ' Paste Special
Ctrl.Enabled = False
Next Ctrl
End Sub
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
Private Sub Workbook_Activate()
On Error Resume Next
With Application
.CutCopyMode = False
.CellDragAndDrop = False
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
.OnKey "+{DEL}", ""
.OnKey "^{INSERT}", ""
End With
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19) ' Copy
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21) ' Cut
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=22) ' Paste
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=755) ' Paste Special
Ctrl.Enabled = False
Next Ctrl
End Sub
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right click menu deactivated." & vbCrLf & _
"For this file:", 16, ""
End Sub
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
With Application
.CutCopyMode = False
.CellDragAndDrop = False
.OnKey "^c", ""
.OnKey "^v", ""
.OnKey "^x", ""
.OnKey "+{DEL}", ""
.OnKey "^{INSERT}", ""
End With
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19) ' Copy
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21) ' Cut
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=22) ' Paste
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=755) ' Paste Special
Ctrl.Enabled = False
Next Ctrl
End Sub
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
Private Sub Workbook_Deactivate()
On Error Resume Next
With Application
.CellDragAndDrop = True
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"
.OnKey "+{DEL}"
.OnKey "^{INSERT}"
.CutCopyMode = False
End With
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19) ' Copy
Ctrl.Enabled = True
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21) ' Cut
Ctrl.Enabled = True
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=22) ' Paste
Ctrl.Enabled = True
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(ID:=755) ' Paste Special
Ctrl.Enabled = True
Next Ctrl
End Sub
'=============================================
'Sekmeas.blogspot.com ===================
'=============================================
របៀប Import និង Export កូដ VBA
Import and Export VBA code
Copy the code in a Standard module of your workbook, if you just started with VBA see this page.Where do I paste the code that I find on the internet
On this page you find some basic VBA code to Import and Export VBA code in Excel for Windows.
You can use it to import modules/userforms to other Excel files or to update the code in other Excel files.
Note: This example not Export/Import the code in sheet modules and from the Thisworkbook module.
Tip: Check out also the two links in the "More Information" part of this page.
The Export macro will export every module(.bas),class module(.cls) and userfom(.frm, .frx) from the ActiveWorkbook to a folder named "VBAProjectFiles" in your Documents folder.
Note: never rename these files manual because the name of the file is not the module name that you
see after you import the code into another Excel workbook.
If you open for example a module file (.bas) in Notepad you see this line of metadata at the top
Attribute VB_Name = "TheNameYouWant"
This is the name that the Module have when you import it into another workbook.
If you edit the name of a module in the properties of the module it will update this line nicely. So if you see names that are not correct after your Export check out this metadata line first. If this line is missing it will use the default Module1, Module2, .......
How does it work ?
1: Open the file with the code from this page2: Open/Activate the file with the modules you want to export
3: Run the ExportModules macro
4: Note: If you look in the VBAProjectFiles folder you see the files now
5: Open/Activate the workbook where you want to add the modules to
6: Run the ImportModules macro (It delete all existing modules/userforms from this Workbook first)
7: Done
The VBA code
Copy every macro and function below into a Standard module of a new workbook and save this Import-Export file as xls or xlsm.Public Sub ExportModules() Dim bExport As Boolean Dim wkbSource As Excel.Workbook Dim szSourceWorkbook As String Dim szExportPath As String Dim szFileName As String Dim cmpComponent As VBIDE.VBComponent ''' The code modules will be exported in a folder named. ''' VBAProjectFiles in the Documents folder. ''' The code below create this folder if it not exist ''' or delete all files in the folder if it exist. If FolderWithVBAProjectFiles = "Error" Then MsgBox "Export Folder not exist" Exit Sub End If On Error Resume Next Kill FolderWithVBAProjectFiles & "\*.*" On Error GoTo 0 ''' NOTE: This workbook must be open in Excel. szSourceWorkbook = ActiveWorkbook.Name Set wkbSource = Application.Workbooks(szSourceWorkbook) If wkbSource.VBProject.Protection = 1 Then MsgBox "The VBA in this workbook is protected," & _ "not possible to export the code" Exit Sub End If szExportPath = FolderWithVBAProjectFiles & "\" For Each cmpComponent In wkbSource.VBProject.VBComponents bExport = True szFileName = cmpComponent.Name ''' Concatenate the correct filename for export. Select Case cmpComponent.Type Case vbext_ct_ClassModule szFileName = szFileName & ".cls" Case vbext_ct_MSForm szFileName = szFileName & ".frm" Case vbext_ct_StdModule szFileName = szFileName & ".bas" Case vbext_ct_Document ''' This is a worksheet or workbook object. ''' Don't try to export. bExport = False End Select If bExport Then ''' Export the component to a text file. cmpComponent.Export szExportPath & szFileName ''' remove it from the project if you want '''wkbSource.VBProject.VBComponents.Remove cmpComponent End If Next cmpComponent MsgBox "Export is ready" End Sub Public Sub ImportModules() Dim wkbTarget As Excel.Workbook Dim objFSO As Scripting.FileSystemObject Dim objFile As Scripting.File Dim szTargetWorkbook As String Dim szImportPath As String Dim szFileName As String Dim cmpComponents As VBIDE.VBComponents If ActiveWorkbook.Name = ThisWorkbook.Name Then MsgBox "Select another destination workbook" & _ "Not possible to import in this workbook " Exit Sub End If 'Get the path to the folder with modules If FolderWithVBAProjectFiles = "Error" Then MsgBox "Import Folder not exist" Exit Sub End If ''' NOTE: This workbook must be open in Excel. szTargetWorkbook = ActiveWorkbook.Name Set wkbTarget = Application.Workbooks(szTargetWorkbook) If wkbTarget.VBProject.Protection = 1 Then MsgBox "The VBA in this workbook is protected," & _ "not possible to Import the code" Exit Sub End If ''' NOTE: Path where the code modules are located. szImportPath = FolderWithVBAProjectFiles & "\" Set objFSO = New Scripting.FileSystemObject If objFSO.GetFolder(szImportPath).Files.Count = 0 Then MsgBox "There are no files to import" Exit Sub End If 'Delete all modules/Userforms from the ActiveWorkbook Call DeleteVBAModulesAndUserForms Set cmpComponents = wkbTarget.VBProject.VBComponents ''' Import all the code modules in the specified path ''' to the ActiveWorkbook. For Each objFile In objFSO.GetFolder(szImportPath).Files If (objFSO.GetExtensionName(objFile.Name) = "cls") Or _ (objFSO.GetExtensionName(objFile.Name) = "frm") Or _ (objFSO.GetExtensionName(objFile.Name) = "bas") Then cmpComponents.Import objFile.Path End If Next objFile MsgBox "Import is ready" End Sub Function FolderWithVBAProjectFiles() As String Dim WshShell As Object Dim FSO As Object Dim SpecialPath As String Set WshShell = CreateObject("WScript.Shell") Set FSO = CreateObject("scripting.filesystemobject") SpecialPath = WshShell.SpecialFolders("MyDocuments") If Right(SpecialPath, 1) <> "\" Then SpecialPath = SpecialPath & "\" End If If FSO.FolderExists(SpecialPath & "VBAProjectFiles") = False Then On Error Resume Next MkDir SpecialPath & "VBAProjectFiles" On Error GoTo 0 End If If FSO.FolderExists(SpecialPath & "VBAProjectFiles") = True Then FolderWithVBAProjectFiles = SpecialPath & "VBAProjectFiles" Else FolderWithVBAProjectFiles = "Error" End If End Function Function DeleteVBAModulesAndUserForms() Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Set VBProj = ActiveWorkbook.VBProject For Each VBComp In VBProj.VBComponents If VBComp.Type = vbext_ct_Document Then 'Thisworkbook or worksheet module 'We do nothing Else VBProj.VBComponents.Remove VBComp End If Next VBComp End Function
របៀបប្រើប្រាស Application.Run ក្នុង Excel
When you want to run a macro from an event or from another macro in the same workbook you can call the macro like this in your code :
Call YourMacroName
You do not have to use Call but I think it is clearer when you read the code that another macro is called.
But what if you want to run a macro that is in another workbook or Add-In(File or add-in must be open).
We can use Application.Run if we want that like this :
Application.Run "Book1.xls!MyMacroName"
If the workbook name includes spaces or some other particular characters it is necessary to enclose the name with single quotes, like this :
Application.Run "'Book 1.xls'!MyMacroName"
It does not do any harm to use the single quotes even if not needed, and always include them if the workbook name is not known in advance, for example if the workbook name is a variable like this
Application.Run "'" & strFileName & "'!MyMacroName"
Note: If your workbook name contains apostrophe (') characters, such as in "Joe's Workbook.xls", then you need to double-up the apostrophes like Application.Run "'Joe''s Workbook'!MyMacroName"
Callbacks instead of macros in Excel 2007 and Excel 2010
But what if you use Excel 2007-2013 and use custom Ribbon controls with callbacks.A normal macro looks like this :
Sub TestMe() MsgBox "Hi there" End SubAnd a callback looks like this :
Sub TestMe(control As IRibbonControl) MsgBox "Hi there" End SubYou will notice that the Application.Run examples above will not work when you want to run a callback in another workbook or Add-in. Also Call MyMacroName will not work to call a callback in the same workbook.
But we can do this to call a callback in the same workbook :
Sub test1() Dim obj As Object TestMe obj End SubOr to call a callback in an add-in or another workbook use :
Sub test2() Dim obj As Object Application.Run "'RDBMerge.xlam'!RunRDBMergeForm", obj End SubNote: Instead of a object you can also use IRibbonControl like this :
Sub test3() Dim IRCdummy As IRibbonControl TestMe IRCdummy End Sub
Check if file or add-in is open
Before you try to run the Application.Run line that call a macro or callback in another workbook or add-in you can test if the workbook or add-in is open with the code below.Sub ErrorTest()
Dim TestWkbk As Workbook
Dim obj As Object
Set TestWkbk = Nothing
On Error Resume Next
Set TestWkbk = Workbooks("RDBTestAdd-in.xlam")
On Error GoTo 0
If TestWkbk Is Nothing Then
MsgBox "Sorry the File is not open, it is not possible to run the macro." & _
" But you can add code here to open the workbook or add-in."
Else
MsgBox "Use one of the two lines below to call the callback or macro"
'Run a callback in a Excel 2007-2013 workbook/add-in
'Application.Run "'" & TestWkbk.Name & "'!RunMyMacro", obj
'If you want to run a macro in a Excel 97-2013 workbook/add-in use
'Application.Run "'" & TestWkbk.Name & "'!RunMyMacro"
End If
End Sub
Tip: You could replace the MsgBox that says that the file is not open
with code that opens the workbook/add-in. Set TestWkbk
= Workbooks.Open("C:\YourPathToTheAddin\RDBTestAdd-in.xlam")Do not forget to check if opening the file was succesful in the code before you try to call the macro or callback.
Returning values from functions or passing arguments to functions or macros
Another way to test if a workbook/add-in is open is to call a function like this with as argument the workbook name that you want to check.Function IsOpen(WBname As String) As Boolean Dim wb As Workbook On Error Resume Next Set wb = Workbooks(WBname) If Err = 0 Then IsOpen = True End FunctionBut how do we use this function if it is not in the same workbook, you can use this to check if there is a file named RDBMerge.xlam open.
Dim MyResult As Boolean
MyResult = Application.Run("'" & TestWkbk.Name & "'!IsOpen", "RDBMerge.xlam")
Or use this to call a macro/function with arguments
Application.Run "'" & TestWkbk.Name & "'!MacroNameHere", "parm1", "parm2"
Acknowledgements
Many thanks to Peter Thornton, Jim Rech, Dave Peterson and Mike Rosenblum for their useful comments.របៀបបង្កើត និងប្រើប្រាស ឯកសារផ្ទាល់ខ្លួនជាមួយកូដ VBA
Information
If you want that certain code is available in all your workbooks, then use your PERSONAL.XLS or in Excel 2007-2013 your PERSONAL.XLSB file.What is it:
This is a hidden workbook that opens when you start Excel.
The code you copy in this workbook is available in all workbooks that are open in Excel.
Where is it:
If it exists, you can find the file in the Excel startup folder.
Windows XP
C:\Documents and Settings\Ron\Application Data\Microsoft\Excel\XLSTART
In Vista or Windows 7/8 look here
C:\Users\Ron\AppData\Roaming\Microsoft\Excel\XLSTART
Note: Ron is the username in the path above
With code you find the correct path on your machine with this line
1) Open excel
2) Hit alt-F11 to get to the VBE
3) Hit ctrl-g to see the immediate window and type this:
4) ?Application.StartupPath
5) Press enter
You’ll see the startup path returned
Note: Application Data and AppData are hidden folders. To show them follow the steps below
Open Windows Explorer
Vista and Windows 7/8: Click on Organize and then on Folder and search options
Windows Xp : Click on Tools and then on Folder Options
Then on all systems on the View tab select show hidden files and folders
How do you create the file if it does not exist:
If it does not exist then record a dummy macro and change the "Store macro in:" drop down to Personal Macro Workbook. Excel creates the file for you then in the correct folder.Excel 97-2003: Tools>Macro…Record New Macro.
Excel 2007-2010: On the “Developer” tab click on Record macro.
To display the Developer tab in Excel 2007 go to Office Button >Excel Options...Popular
In Excel 2010-2013 : File>Options..Customize Ribbon, check Developer in the Main Tabs list.
Or faster click the button on the bottom left corner of the Excel 2007-2013 window to start the recording.
Press OK in the dialog that you see now
Because we only want Excel to create the file for us we can stop the recording directly.
Press the Stop Recording button or use Tools>Macros…Stop recording in Excel 97-2003
In Excel 2007-2013 you can press the Stop Recording Button on the Developers tab or click the
button on the bottom left corner of the Excel window to stop the recording.
Now we use Alt F11 to go to the VBE editor(working in all Excel versions) Or:
Excel 97-2003: Tools>Macro>Visual Basic Editor.
Excel 2007-2013: Click on the button named “Visual Basic” on the “Developer” tab
Note: I use the name PERSONAL.XLS in the screenshots below but in Excel 2007-2013 the name is PERSONAL.XLSB. To be sure that we see the Project Window, Code window and the Properties window we use one time.
Ctrl-r (to see the project explorer)
F7 (to view the code window)
F4 (to view the properties window)
Now we give the PERSONAL.XLS(b) a unique project name (Default is VBAProject)
Select the PERSONAL.XLS(b) in the project window and change the name in the properties window.
Now use Ctrl-s or File>Save in the VBA editor to save the PERSONAL file
We are now ready to add code (macros or/and functions) to this file so we can use it in all workbooks.
With Insert>Module in the VBA editor you can also add more modules to the PERSONAL.XLS. This way you can organize your code in this file. Use only code here that you use yourself and not code that you use in files that you distribute to other users. In this case add the code in the modules of the workbook itself. Or distribute your VBA macros as a Add-in.
Example 1 : Macro
Public Sub Test() MsgBox "Insert your favorite code here" End Sub1) Select the PERSONAL.XLS(b) in the project window and click on the + before it
2) Then click on the + before Modules
3) Double click on Module1 to open the code window on the right
4) We copy/paste the example macro in this module.
5) Now use Ctrl-s or File>Save in the VBA editor to save the PERSONAL.XLS(b).
6) We use Alt–q to go back to Excel or use "File >Close and Return to Microsoft Excel".
7) You can run the macro then with Alt-F8 or Tools>Macro…Macros / Developer tab>Macros
Note: You can delete the dummy macro that we used to create the PERSONAL.XLS(b).
Example 2: Function
This function(UDF) gives you the ISO week number that is used in Europe and a lot of other countries.Note: This function is only available in Excel 2010 and higher (=WEEKNUM(C5,21), see the argument 21.
Public Function IsoWeekNum(d1 As Date) As Integer
' Daniel Maher
Dim d2 As Long
d2 = DateSerial(Year(d1 - Weekday(d1 - 1) + 4), 1, 3)
IsoWeekNum = Int((d1 - d2 + Weekday(d2) + 5) / 7)
End Function
1) Select the PERSONAL.XLS(b) in the project window and click on the +
before it2) Then click on the + before Modules
3) Double click on Module1 to open the code window on the right
4) We copy/paste the example function in this module.
5) Now use Ctrl-s or File>Save in the VBA editor to save the PERSONAL.XLS(b).
6) We use Alt–q to go back to Excel or use "File >Close and Return to Microsoft Excel".
Now we can use this in a worksheet cell with the date in A1
=PERSONAL.XLS!IsoWeekNum(A1)
If you create a reference in the workbook where you want to use it to your
PERSONAL.XLS(b) then you can use
=IsoWeekNum(A1)
Go to Tools>References in the VBA editor with the workbook selected in the project window and
add a check mark before RonPersonal. (Save the workbook then)
Problems with the PERSONAL.XLS(B) workbook
What to do if your PERSONAL.XLS(b) is visibleWhen you open Excel and you see PERSONAL.XLS(B) in the title bar you can use this to hide it.
Excel 97-2003 : Window>Hide
Excel 2007-2010 : On the View tab in the window group choose Hide
Then close Excel and say Yes to save the changes to your PERSONAL file.
PERSONAL.XLS(b) will not open but is in the correct location
When Excel think the file is corrupt it can disable the file.
You can re-enable it here but if it is really corrupted replace it with a backup.
Excel 2002-2003 : Help>About MS Excel>Disabled items
Excel 2007 : Office button>Excel Options..Add-ins
In the "Manage:" dropdown (bottom of the dialog)
Choose "Disabled Items
Go
Excel 2010-2013 : File>Options..Add-ins
In the "Manage:" dropdown (bottom of the dialog)
Choose "Disabled Items
Go
Use a Add-in
You can also create an add-in to store code that you and others want to use in all workbooks.This is a good way if you want to distribute code to other users.
Read this article from Jan Karel Pieterse
http://www.jkp-ads.com/Articles/DistributeMacro00.asp
របៀបចម្លងកូដដែលស្វែងរកបានពីអ៊ីនធឺណិត
Where do I paste the code that I find on the internet
When you want to try VBA code that you see in a Forum, Newsgroup or WebSite and you read:Paste the code in a General, Regular, Normal or Standard module
Paste the code in a Sheet module
Paste the code in the ThisWorkbook module
And you have no idea where to paste the code then I hope the screenshots below will help you. If you are on a Mac see also the links on the bottom of this page. There are four types of modules and there are screenshots for the first two on this page.
ThisWorkbook and worksheet code modules
You find them in the Microsoft Excel Objects folder and you use them to store event macros
General, Regular, Normal or Standard code modules
Here you store normal macros, User Defined Functions(UDFs) and global variables.
You can have more then one module in your project
UserForm modules
Here you store the event code for the Userform
Class modules
See this page for more information
http://cpearson.com/excel/AppEvent.aspx
Open the VBA editor
Open the VBA editor with the shortcut Alt+F11.You see that you can use Ctrl+r to open the Project Explorer if you not see it.
The Project Explorer is like Windows Explorer and you can see all your open workbooks
and add-ins there.
Normal the active project (workbook) is expand so you can see all the modules in it.
But if you see this press the * on the numeric keyboard with the project selected to expand your project.
You can also click on the + or double click the project name.
Tip: Use Option Explicit in every module
If used, the Option Explicit statement must appear before any other code.
When you use Option Explicit you must explicitly declare all variables.
If you attempt to use an undeclared variable name, an error occurs at compile time.
It avoid incorrectly typing the name of an existing variable and avoid confusion
in code where the scope of the variable is not clear.
If you not declare your variable it will be a Variant, Variants are slow, they take up a lot of memory,
and using them when not absolutely necessary can create hard-to-find bugs in your code
To add Option Explicit automatic in every new module or every module in a new file use this
Tools>Options in the menu bar and check "Require Variable Declaration".
Paste code in a General, Regular, Normal or Standard module
You must insert a module first in your project before you can use it for code.Click on Insert>Module with your project active in the Menu bar to do this.
Select the module in the Project Explorer and press F7 or double click on the module.
You can see above the menu bar if you have the code window of the correct module active.
The module is directly active after you insert it in your project for the first time.
Paste the code in the code window on the right hand side below Option Explicit.
After you paste the code in the code window use Alt+q to go back to Excel.
In Excel you can use Alt+F8 then to select the macro and run it.
Paste code in a Sheet module
Select the sheet in the Project Explorer and press F7 or double click on the sheet module.You can see above the menu bar if you have the code window of the correct module active.
Another way to go to a sheet module is to right click on a sheet tab and choose "View Code"
You not have to open the VBA editor first when you use this.
Paste the code in the code window on the right hand side below Option Explicit.
After you paste the code in the code window use Alt+q to go back to Excel.
Paste code in the ThisWorkbook module
Select ThisWorkbook in the Project Explorer and press F7 or double click on the ThisWorkbook module.You can see above the menu bar if you have the code window of the correct module active.
Paste the code in the code window on the right hand side below Option Explicit.
After you paste the code in the code window use Alt+q to go back to Excel.