Posts

Showing posts from November, 2011

Automating FTP PUT Jobs from UNIX to a Windows FTP Server

Last month I had to find a way to automate the transfer of files from a UNIX database server to a Windows fileshare via the pre-existing FTP method. This was previously executed manually. The trouble I ran into was passing the FTP commands from a UNIX shell script to the Windows FTP server (specifically, user credentials) correctly. Second, I also wanted to automate the process of archiving these files to a new directory after transfer. Here's what I came up with, variables requiring your modification in bold: ################################################################################ #************************* Script Title ****************************** # # Script Name: FTP PUT TO WINDOWS FTP SERVER # Script Filename: FTP_PUT_TO_WINFTPSERVER.sh # # #********************* Script Description ************************************ # # This shell script will look for files matching 'FTP_*.dat' and FTP any # found to a Windows FTP server, then archive them in a fold

Combine Multiple Excel Workbooks Into A Single File

Recently, I had to combine many worksheets of individual server security risk forms into a single workbook. Obviously, I'd rather research a script to do this than manually combine 47 separate files. Finally located another much more scripting-capable individual who had accomplished this with the below Excel macro code. Additionally, my worksheets were protected, so another script was used to perform this process en masse. Option Explicit '32-bit API declarations Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal _ pszpath As String) As Long Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) _ As Long Public Type BrowseInfo hOwner As Long pIDLRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type Function GetDirect

Unprotect All Excel Sheets for All Workbooks in a Directory

This Excel macro came in very handy when I had a set of workbooks in a folder (and subfolders) that all needed unprotected before running another macro to combine all of the workbooks into a single file. Be sure to update the bolded variables below.  Source . Const cStartFolder = " C:\Documents and Settings\UserName\My Documents\Spreadsheets " 'no slash at end Const cFileFilter = " *.xlsx " Const cPassword = " CleverPassword " 'use empty quotes if blank Sub UnprotectAllWorksheets() Dim i As Long, j As Long, arr() As String, wkb As Workbook, wks As Worksheet ExtractFolder cStartFolder, arr() On Error Resume Next j = -1: j = UBound(arr) On Error GoTo 0 For i = 0 To j Set wkb = Workbooks.Open(arr(i), False) For Each wks In wkb.Worksheets wks.Unprotect cPassword Next wkb.Save wkb.Close Next End Sub Sub ExtractFolder(Folder As String, arr() As String) Dim i As Long, objF

Find and Delete All Blank Rows in an Excel Sheet

Quick tip that I use fairly often when weeding out certain rows in reports: Select the column containing blanks. Press F5 ("Go to") on your keyboard. Click Special . Check Blanks . Click OK . Right click a blank cell in the appropriate column. Click Delete > Entire row . Click OK .