Skip to main content

Posts

Showing posts from November, 2014

Unable to print word 2010 document

Assuming the printer is setup properly, and able to print from PDF, notepad or other software and also able to print from printer driver test page. But when printing a specific word document in Word 2010, it will just show "Not responding" the document will hang and will not print. There is no restriction set on the document but cannot print. Try steps below: Click on the "File" tab, click on the "Review" menu. From the "Review" tab, select "tracking" change the option from: "Final: Show Markup" to "Final". Check image below: Save the document or save it to a different file name. And try printing again, if everything goes right the document will be able to print. Paper tray settings will also cause a problem with printing the document. Documents from another party that retain printer settings on the document will not print if the printer of the other party does not have...

Android R not generated

Ever encountered why Android R is not generated? One quick solution is to delete the “gen” folder hoping, that it will be generated again since the folder is auto generated. But it works sometimes..  But if Android will not auto generate the R and problem will be not washed away. And after deletion the problem still exists, and even after cleaning the project. So now what? If the XML in the "res" folder, such as the "layout" XML and "drawables" XML (drawable-hdpi, drawable-xhdpi etc..) if the XML has errors on any of these folders, it will cause R not to be generated. If the XML are all okay and still R is not generated.  Then open the drawables folder, if any of the PNG or any images its filenames has to be in lower case and filenames should only contain lower case letters and numbers. So images on the drawable folders which has Upper Case letters will cause the R not to be generated. File names of images on the dra...

Folder Redirection still points to old server

Folder Redirection still points to old server for Windows 7. A quick work around is to create a hosts file on the workstation with the old server name but the IP Address points to the new server. Be sure to make a backup of the users folder before making any changes. DON'T MAKE an A record (or a host record) on the DNS server for the  old server, or you will end up with a disaster. Just the hosts file on the workstation. Hope it helps.. :)

Excel VBA display message in cell click

Excel VBA display a message once a specified cell is click. Popup a message box on Excel when a particular cell is click by the user. Here's the simple VBA code snippet: //======================= Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim xtarget   'this message will always display which ever cell is click on the worksheet     MsgBox Target.Address & " is selected" xtarget = Target.Address 'if A1 is click msgbox message below will be displayed If xtarget = "$A$1" Then MsgBox "You selected A1, please don't harm the value" End If End Sub //======================= The code can be tweak also to display the cell comment on the message box. //======================= Private Sub Worksheet_SelectionChange(ByVal Target As Range)   Dim xtarget xtarget = Target.Address Dim varxComment As String Dim xcom As Comment With Range(xtarge...

Linux Bash Shell get x days ago

Bash script to get x days from current date. Get yesterday's date, 2 days ago or any desired date prior from the current date. Here's the script with comment on each line: //=============================== #!/bin/sh xdate1=$(date -d "-1 day" +"%Y%m%d") echo $xdate1 #will return yesterday's date #Output sample: #20141001 xdate2=$(date -d "-2 day" +"%Y%b%d") echo $xdate2 #will return 2 days before the current date #Output sample: #2014Sep30 #below is just an example on how to cut the variable into year, month and day of the month #if xdate1 has the value of -20141001 xcutDate1=${xdate1:7:2} #will return 01 #will return the date of the month #if xdate1 has the value of -2014Oct01 xcutDateMonth2=${xdate2:4:3} #will return Oct #will return month #if xdate1 has the value of -2014Oct01 xcutYear1=${$xdate1:0:4} #will return 2014 #will return the yea r echo $xcutYear1 $xcutDateMonth2 #will display the year and the month #xToday will ...

Excel VBA get x days ago

A quick code snippet to get yesteday's date or a week before from the date the macro is executed.   Sub xDate() Dim yesterdaysdate, aweekbeforefromtoday aweekbeforefromtoday = Format(DateAdd("D", -Weekday(Date) - 1, Date), "dd-mmm-yy") yesterdaysdate = Format(DateAdd("D", -1, Date), "dd-mmm-yy") MsgBox yesterdaysdate MsgBox aweekbeforefromtoday End Sub A variable can be set to easily change the desired number of days before the current date.  Example: xMinusDays = -2 yesterdaysdate = Format(DateAdd("D", xMinusDays, Date), "dd-mmm-yy") xMinusDays is set to -2 will return 2 days before the current date If  xMinusDays is set to -5 then it will return 5 days before from the current date //=========================== VBA code below will return x days ago depends on the value set on the parameter. To implement in VBA code: ============================= Sub xDate() Dim xMinusDays xMinusDays = -365 Dim ...

PowerShell search file contents

PowerShell has a lot of features that makes life of a System Administrator easier. But if you haven't learned PowerShell then it’s quite hard to appreciate the beauty of it. Learn PowerShell and you will learn to love the power it brings. On this example below, is quite a good and useful feature. Log files are quite important, it will help to record data and keep track or monitor any activities on the system. Example, if you have a log file or ".txt" files that keeps track of IP Addresses that connects to a particular server. And need to check whether a particular IP Address has connected to the server. One way, of course is to open one by one the log files. Another way is to automate the process using PowerShell and let PowerShell do the task. The code snippet below will browse through the text files in a directory and PowerShell will read or get the contents of  the text file and will check if the string specified will match its content. If the str...

PowerShell Move or copy files with specific date

Below is a simple PowerShell code that will move, list or copy files on a specific date. Assign or change specific date on $xCompareDate to any desired date. Of course, PowerShell has option also to move, list or copy files older or greater than x days. But if there is a need to have a specific date, this script will come handy. #=============== $xfile = Get-ChildItem  -Path d:\Logs -File | #Get the full path, file name and the creation time of the file Select-Object FullName, CreationTime | Where-Object {       #convert the creation time to string to compare dates       $xfile = $_.CreationTime.Date.Month.ToString()  + "/" + ($_.CreationTime).Date.day.ToString() + "/" +  ($_.CreationTime).Date.year.ToString()                   $xCompareDate=  "10/21/2014"     #conditional statement if files are equal to the date compa...

Directory listing with PowerShell

PowerShell list all files in a directory. To list all files in a directory is quite easy using PowerShell, as long as the path does not exceeds the path limitation. Using the parameter " -Recurse " will include sub-folders on the path specified. " .FullName " option will include the path and the file name. If  ".FullName" is not specified, will list only the file name without the path. If don't need to include files on sub folders omit or remove "-Recurse" option. ========================   $xfile = Get-ChildItem -Recurse -Path D:\MyMusicMP3 foreach ($filename in $xfile) { write-host $filename.FullName } $xfile = Get-ChildItem -Recurse -Path D:\ MyMusicMP3 foreach ($filename in $xfile) { write-host $filename } ======================== == Script below will list only the files on the root directory specified; sub folder files will not be listed. $xfile = Get-ChildItem  -Path D:\MyFolder foreach ($filename in $xfile) { write...

Run PowerShell script in Task Scheduler

How to run a PowerShell script using Windows Task Scheduler? Please see image below on how to setup PowerShell script using Windows Task Scheduler. In Program/Script textbox, type: PowerShell.exe or type the whole path to PowerShell.exe In Add arguments (optional) textbox type:    -WindowStyle Hidden -File c:\Monitor.ps1    -WindowStyle Hidden === optional parameter to hide the PowerShell script when it runs    -File c:\Monitor.ps1 === path parameter where the script resides Check out this Technet link for optional parameters on how to launch PowerShell. http://technet.microsoft.com/en-us/magazine/ff629472.aspx Or you can just put the parameters on batch file and call the batch file via the task scheduler. Type line below on a notepad and save it as a batch file ".bat". PowerShell.exe -WindowStyle Hidden  -File c:\Monitor.ps1   Directly setting the PowerShell file on Task Scheduler may resolve to indefinite task t...

How to open a text file in Excel?

Excel can read and open text files. Excel, Word or any text editing software can read, open any text file. When opening the file on Excel, formatting will be an issue. If text file values or data need to arrange by columns or by rows, then it could be daunting to import the file to Excel. But if the text file is properly formatted, like values are separated by tab, comma or other symbols to segregate values or basically any delimiter characters Excel will open the text file as CSV or comma separated values without any issue. If the text file exported from a program that has delimiters or any text file separated by delimiters then importing process to Excel will be easier. Values will be separated based on the delimiters detected on the file. If the file delimiter is a "tab" character or tab-delimited text file, values or data will be separated based on "tab" spacing. Example: "tab" refers to the actual tab, which correspond to number of ...

PowerShell Get Information About Computer

A simple PowerShell code snippet that retrieves information’s on remote computers. This code will work fine if  WinRM  or Winwdows Remote Management is configured properly on the remote computer. And the user account has the right credentials to logon remotely on the remote computer. If run on a domain controller with the proper privileges and remote management is configured on client computer, the PowerShell code below will work fine. ============================ #set the computer name $computer = "FileServer" #cmdlet to logon the computer specified on the parameter Enter-PSSession -ComputerName $computer # get all drives information, including free hard drive space Get-WmiObject Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3} #get bios information on the remote computer Get-WmiObject Win32_bios #get  available printers installed on the remote computer Get-WmiObject Win32_printer #get mapped drives set on the remote computer Get...