Sub aaInsertImagesOneToAPage()
Dim doc As Word.Document
Dim fd As FileDialog
Dim vItem As Variant
Dim mg1 As Range
Dim mg2 As Range
Dim intCount As Integer
Dim strTotal As String
strTotal = ""
intCount = 0
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set doc = ActiveDocument
Dim shapePicture As InlineShape
' Set the width or the height
Dim intSetWidth
Dim intSetHeight
intSetWidth = 350
intSetHeight = 350
Dim dblPercentChange As Double
dblPercentChange = 1
'==Prompt user for Case Title:
Dim strCaseTitle As String
strCaseTitle = InputBox("Enter a title for the case :", "Case Title")
Dim blImageAdjusted As Boolean
With fd
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1
.FilterIndex = 1
blImageAdjusted = False
If .Show = -1 Then
For Each vItem In .SelectedItems
intCount = intCount + 1
Set mg2 = ActiveDocument.Range
mg2.ParagraphFormat.Alignment = wdAlignParagraphCenter
mg2.Collapse wdCollapseEnd
Set shapePicture = doc.InlineShapes.AddPicture( _
FileName:=vItem, _
LinkToFile:=False, SaveWithDocument:=True, Range:=mg2)
' Resize portait and landscape picture differently
' Resize portrait by height and resize landscape by width
' Portrait - resize by height
If shapePicture.Height > shapePicture.Width Then
' if we are not the height we we want, resize by percent
If shapePicture.Height <> intSetHeight Then
blImageAdjusted = True
dblPercentChange = CDbl(intSetHeight / shapePicture.Height)
shapePicture.Width = shapePicture.Width * dblPercentChange
shapePicture.Height = shapePicture.Height * dblPercentChange
End If
Else
' this is for square or landscape images
If shapePicture.Width <> intSetWidth Then
blImageAdjusted = True
dblPercentChange = CDbl(intSetWidth / shapePicture.Width)
shapePicture.Width = shapePicture.Width * dblPercentChange
shapePicture.Height = shapePicture.Height * dblPercentChange
End If
End If ' Portrait or Landscape
Set mg1 = ActiveDocument.Range
mg1.Collapse wdCollapseEnd
strTotal = CStr(.SelectedItems.Count)
If strCaseTitle <> "" Then
mg1.Text = ""
mg1.Text = vbCrLf + strCaseTitle + ". "
mg1.Text = mg1.Text + "Height wanted = " + CStr(intSetHeight) + "Actual height=" + CStr(shapePicture.Height)
mg1.Text = mg1.Text + " Height Percent=" + CStr(dblPercentChange)
mg1.Text = mg1.Text + "Image: " + CStr(intCount) + " of " + strTotal
mg1.Text = mg1.Text + vbCrLf + "width=" + CStr(shapePicture.Width) + " height " + CStr(shapePicture.Height)
If blImageAdjusted Then
mg1.Text = mg1.Text + vbCrLf + "Image WAS adjusted" & vbCrLf
Else
mg1.Text = mg1.Text + vbCrLf + "Image was NOT adjusted" & vbCrLf
End If ' was image adjusted
End If ' strCaseTitle is blank
'Insert a page break
mg1.InsertBreak (7)
Next vItem
End If
End With
Set fd = Nothing
End Sub ' InsertImagesOfHeight
Posts from a Lotus Notes Client and Domino programmer from Sydney.
Monday, 20 March 2017
SetAllImages In Word doc to one size
Sub aSetAllPicturesSize()
Dim i As Long
Dim strNewWidth As String
strNewWidth = InputBox("Enter a width for all images: (eg 450)", "Image Size")
Dim intNewWidth As Integer
intNewWidth = CInt(strNewWidth)
Dim intNewHeight As Integer
intNewHeight = CInt(intNewWidth * 0.8)
Dim dblPercentChange As Double
With ActiveDocument
For i = 1 To .InlineShapes.Count
With .InlineShapes(i)
If .Height > .Width Then
' if we are not the height we we want, resize by percent
If .Height <> intNewHeight Then
dblPercentChange = CDbl(intNewHeight / .Height)
.Width = .Width * dblPercentChange
.Height = .Height * dblPercentChange
End If
Else
' this is for square or landscape images
If .Width <> intNewWidth Then
dblPercentChange = CDbl(intNewWidth / .Width)
.Width = .Width * dblPercentChange
.Height = .Height * dblPercentChange
End If
End If ' Portrait or Landscape
End With
Next i
End With
End Sub
Dim i As Long
Dim strNewWidth As String
strNewWidth = InputBox("Enter a width for all images: (eg 450)", "Image Size")
Dim intNewWidth As Integer
intNewWidth = CInt(strNewWidth)
Dim intNewHeight As Integer
intNewHeight = CInt(intNewWidth * 0.8)
Dim dblPercentChange As Double
With ActiveDocument
For i = 1 To .InlineShapes.Count
With .InlineShapes(i)
If .Height > .Width Then
' if we are not the height we we want, resize by percent
If .Height <> intNewHeight Then
dblPercentChange = CDbl(intNewHeight / .Height)
.Width = .Width * dblPercentChange
.Height = .Height * dblPercentChange
End If
Else
' this is for square or landscape images
If .Width <> intNewWidth Then
dblPercentChange = CDbl(intNewWidth / .Width)
.Width = .Width * dblPercentChange
.Height = .Height * dblPercentChange
End If
End If ' Portrait or Landscape
End With
Next i
End With
End Sub
Tuesday, 1 November 2016
Single use tablets - the contact list for the office
http://www.techzone360.com/topics/techzone/articles/2014/12/08/394794-single-use-tablets-thinking-differently-under-100-tablets.htm#
http://www.zdnet.com/article/understanding-the-dichotomy-between-single-use-and-multifunctional-tablets/
http://www.zdnet.com/article/understanding-the-dichotomy-between-single-use-and-multifunctional-tablets/
Sunday, 17 July 2016
Microsoft Word Macro to paste images Sub PasteImageCertainHeight()
Sub PasteImageCertainHeightOrText()
'
' PasteImageCertainHeight Macro
intDesiredWidth = 250
intDesiredHeight = 380
Selection.Paste
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
ScaleValue = 1 ' default no change.
'atk 17/7/2016 created from web
' I like to add this code to be called on ctrl shift v
If Selection.InlineShapes.Count <> 0 Then
' if there is an inline shape, we are pasting picture
If Selection.InlineShapes(1).Height > intDesiredHeight Then
ScaleValue = intDesiredHeight / Selection.InlineShapes(1).Height
intNewHeight = Selection.InlineShapes(1).Height * ScaleValue
intNewWidth = Selection.InlineShapes(1).Width * ScaleValue
End If ' check height
'confirm we are not too wide either
If intNewWidth > intDesiredWidth Then
ScaleValue = intDesiredWidth / intNewWidth
intNewHeight = Selection.InlineShapes(1).Height * ScaleValue
intNewWidth = Selection.InlineShapes(1).Width * ScaleValue
End If ' check width
'Modify the values by the ScaleValue
Selection.InlineShapes(1).Height = Selection.InlineShapes(1).Height * ScaleValue
Selection.InlineShapes(1).Width = Selection.InlineShapes(1).Width * ScaleValue
Else
' pasting text,
Selection.PasteSpecial DataType:=wdPasteText
End If ' ' count of shapes to determine if pasting picture or tex
End Sub ' PasteImageCertainHeight
Sub PasteSpecial()
' I assign this to shortcut key ctrl-alt-v
Selection.PasteSpecial DataType:=wdPasteText
End Sub
'
' PasteImageCertainHeight Macro
intDesiredWidth = 250
intDesiredHeight = 380
Selection.Paste
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
ScaleValue = 1 ' default no change.
'atk 17/7/2016 created from web
' I like to add this code to be called on ctrl shift v
If Selection.InlineShapes.Count <> 0 Then
' if there is an inline shape, we are pasting picture
If Selection.InlineShapes(1).Height > intDesiredHeight Then
ScaleValue = intDesiredHeight / Selection.InlineShapes(1).Height
intNewHeight = Selection.InlineShapes(1).Height * ScaleValue
intNewWidth = Selection.InlineShapes(1).Width * ScaleValue
End If ' check height
'confirm we are not too wide either
If intNewWidth > intDesiredWidth Then
ScaleValue = intDesiredWidth / intNewWidth
intNewHeight = Selection.InlineShapes(1).Height * ScaleValue
intNewWidth = Selection.InlineShapes(1).Width * ScaleValue
End If ' check width
'Modify the values by the ScaleValue
Selection.InlineShapes(1).Height = Selection.InlineShapes(1).Height * ScaleValue
Selection.InlineShapes(1).Width = Selection.InlineShapes(1).Width * ScaleValue
Else
' pasting text,
Selection.PasteSpecial DataType:=wdPasteText
End If ' ' count of shapes to determine if pasting picture or tex
End Sub ' PasteImageCertainHeight
Sub PasteSpecial()
' I assign this to shortcut key ctrl-alt-v
Selection.PasteSpecial DataType:=wdPasteText
End Sub
Tuesday, 21 June 2016
Greasemonkey/Tampermonkey to remove certain rows from a html table
// ==UserScript==
// @name ModifyUFCPageOnlyUltimateClasses
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://www.ufcgymsydney.com/home/programming/class_schedule.aspx
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
//===================================================================================
function ShowOrHideOthers(strShowOrHide) {
var tableOfClasses = document.getElementById('ctl00_phBody_gvClasses');
if (strShowOrHide == "hide") {
strDisplay="none";
} else {
strDisplay= "block";
alert("will show em");
}
var intPosOfClassType=3;
// loop through all rows in the class table - start at row 2
for(var i=2; i
// FIX THIS
try {
var strClassType=(tableOfClasses.rows[i].cells[intPosOfClassType].innerHTML);
if (strClassType!="Ultimate") {
//alert(strClassType);
tableOfClasses.rows[i].style.display = strDisplay;
} // alert for ultimate classes
}
catch(err) {
// this is if we can't read the innerHTML of rows with only 1 cell... ignore it. alert(err.message);
}
} // for each row
}
// end function show or hide others
//===================================================================================
if (confirm("Would you like to only show ultimate classes (tampermonkey script by atk)") === true) {
ShowOrHideOthers("hide");
}
// @name ModifyUFCPageOnlyUltimateClasses
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://www.ufcgymsydney.com/home/programming/class_schedule.aspx
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
//===================================================================================
function ShowOrHideOthers(strShowOrHide) {
var tableOfClasses = document.getElementById('ctl00_phBody_gvClasses');
if (strShowOrHide == "hide") {
strDisplay="none";
} else {
strDisplay= "block";
alert("will show em");
}
var intPosOfClassType=3;
// loop through all rows in the class table - start at row 2
for(var i=2; i
// FIX THIS
try {
var strClassType=(tableOfClasses.rows[i].cells[intPosOfClassType].innerHTML);
if (strClassType!="Ultimate") {
//alert(strClassType);
tableOfClasses.rows[i].style.display = strDisplay;
} // alert for ultimate classes
}
catch(err) {
// this is if we can't read the innerHTML of rows with only 1 cell... ignore it. alert(err.message);
}
} // for each row
}
// end function show or hide others
//===================================================================================
if (confirm("Would you like to only show ultimate classes (tampermonkey script by atk)") === true) {
ShowOrHideOthers("hide");
}
Tuesday, 25 November 2014
Sub InsertImages3ToAPage() - Word Macro
Sub CloseExplorer()
'
' CloseExplorer Macro
'
'
End Sub
Sub InsertImages3ToAPage()
Call InsertImagesOfHeight(170)
End Sub
Sub InsertImages()
Call InsertImagesOfHeight(350)
End Sub 'InsertImages()
Sub InsertImagesOfHeight(intHeight)
Dim doc As Word.Document
Dim fd As FileDialog
Dim vItem As Variant
Dim mg1 As Range
Dim mg2 As Range
Dim intCount As Integer
Dim strTotal As String
strTotal = ""
intCount = 0
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set doc = ActiveDocument
Dim shapePicture As InlineShape
'intSetWidth = 400
Dim dblPercentHeight As Double
dblPercentHeight = 1
'==Prompt user for Case Title:
Dim strCaseTitle As String
strCaseTitle = InputBox("Enter a title for the case :", "Case Title")
With fd
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1
.FilterIndex = 1
If .Show = -1 Then
For Each vItem In .SelectedItems
intCount = intCount + 1
Set mg2 = ActiveDocument.Range
mg2.Collapse wdCollapseEnd
Set shapePicture = doc.InlineShapes.AddPicture( _
FileName:=vItem, _
LinkToFile:=False, SaveWithDocument:=True, Range:=mg2)
' if we are bigger than we want, resize by percent
If shapePicture.Height > intHeight Then
dblPercentHeight = CDbl(intHeight / shapePicture.Height)
shapePicture.Width = shapePicture.Width * dblPercentHeight
shapePicture.Height = shapePicture.Height * dblPercentHeight
End If
Set mg1 = ActiveDocument.Range
mg1.Collapse wdCollapseEnd
strTotal = CStr(.SelectedItems.Count)
mg1.Text = ""
mg1.Text = vbCrLf + strCaseTitle + ". "
'mg1.Text = mg1.Text + "Height wanted = " + CStr(intHeight) + "Actual height=" + CStr(shapePicture.Height)
'mg1.Text = mg1.Text + " Height Percent=" + CStr(dblPercentHeight)
mg1.Text = mg1.Text + "Image: " + CStr(intCount) + " of " + strTotal
'mg1.Text = mg1.Text + vbCrLf + "width=" + CStr(shapePicture.Width) + " height " + CStr(shapePicture.Height)
mg1.Text = mg1.Text + vbCrLf & vbCrLf
Next vItem
End If
End With
Set fd = Nothing
End Sub ' InsertImagesOfHeight
'
' CloseExplorer Macro
'
'
End Sub
Sub InsertImages3ToAPage()
Call InsertImagesOfHeight(170)
End Sub
Sub InsertImages()
Call InsertImagesOfHeight(350)
End Sub 'InsertImages()
Sub InsertImagesOfHeight(intHeight)
Dim doc As Word.Document
Dim fd As FileDialog
Dim vItem As Variant
Dim mg1 As Range
Dim mg2 As Range
Dim intCount As Integer
Dim strTotal As String
strTotal = ""
intCount = 0
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set doc = ActiveDocument
Dim shapePicture As InlineShape
'intSetWidth = 400
Dim dblPercentHeight As Double
dblPercentHeight = 1
'==Prompt user for Case Title:
Dim strCaseTitle As String
strCaseTitle = InputBox("Enter a title for the case :", "Case Title")
With fd
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1
.FilterIndex = 1
If .Show = -1 Then
For Each vItem In .SelectedItems
intCount = intCount + 1
Set mg2 = ActiveDocument.Range
mg2.Collapse wdCollapseEnd
Set shapePicture = doc.InlineShapes.AddPicture( _
FileName:=vItem, _
LinkToFile:=False, SaveWithDocument:=True, Range:=mg2)
' if we are bigger than we want, resize by percent
If shapePicture.Height > intHeight Then
dblPercentHeight = CDbl(intHeight / shapePicture.Height)
shapePicture.Width = shapePicture.Width * dblPercentHeight
shapePicture.Height = shapePicture.Height * dblPercentHeight
End If
Set mg1 = ActiveDocument.Range
mg1.Collapse wdCollapseEnd
strTotal = CStr(.SelectedItems.Count)
mg1.Text = ""
mg1.Text = vbCrLf + strCaseTitle + ". "
'mg1.Text = mg1.Text + "Height wanted = " + CStr(intHeight) + "Actual height=" + CStr(shapePicture.Height)
'mg1.Text = mg1.Text + " Height Percent=" + CStr(dblPercentHeight)
mg1.Text = mg1.Text + "Image: " + CStr(intCount) + " of " + strTotal
'mg1.Text = mg1.Text + vbCrLf + "width=" + CStr(shapePicture.Width) + " height " + CStr(shapePicture.Height)
mg1.Text = mg1.Text + vbCrLf & vbCrLf
Next vItem
End If
End With
Set fd = Nothing
End Sub ' InsertImagesOfHeight
Wednesday, 6 August 2014
Adding Images to Microsoft word automatically
Option Explicit
Sub AKInsertImages()
' v2 31 December 2014
Dim doc As Word.Document
Dim fd As FileDialog
Dim vItem As Variant
Dim mg1 As Range
Dim mg2 As Range
Dim intCount As Integer
Dim strTotal As String
strTotal = ""
intCount = 0
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set doc = ActiveDocument
Dim shapePicture As InlineShape
Dim intSetWidth As Integer
Dim intSetHeight As Integer
' **************************************
intSetWidth = 375
intSetHeight = 400
' **************************************
Dim dblPercentResize As Double
dblPercentResize = 1
' **************************************
' Get Title, Description, Taken By
' **************************************
' eg
' Bicycle Robbery 13 November 2014.
' Taken By: Detective MCGILL. Image: 9 of 9
' Desc:
Dim strCaseTitle As String
Dim strTakenBy As String
strCaseTitle = InputBox("Case Title", "Please enter case title")
strTakenBy = InputBox("Photographed By", "Please enter who took the photo")
With fd
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1
.FilterIndex = 1
If .Show = -1 Then
For Each vItem In .SelectedItems
intCount = intCount + 1
Set mg2 = ActiveDocument.Range
mg2.Collapse wdCollapseEnd
Set shapePicture = doc.InlineShapes.AddPicture( _
FileName:=vItem, _
LinkToFile:=False, SaveWithDocument:=True, Range:=mg2)
' if we are wider than we want, resize percentage
If shapePicture.Width > intSetWidth Then
dblPercentResize = CDbl(intSetWidth / shapePicture.Width)
shapePicture.Width = shapePicture.Width * dblPercentResize
shapePicture.Height = shapePicture.Height * dblPercentResize
End If
' if we are higher than we want, resize percentage
If shapePicture.Height > intSetHeight Then
dblPercentResize = CDbl(intSetHeight / shapePicture.Height)
shapePicture.Width = shapePicture.Width * dblPercentResize
shapePicture.Height = shapePicture.Height * dblPercentResize
End If ' height
Set mg1 = ActiveDocument.Range
mg1.Collapse wdCollapseEnd
strTotal = CStr(.SelectedItems.Count)
mg1.Text = ""
mg1.Text = vbCrLf + "Image: " + CStr(intCount) + " of " + strTotal
mg1.Text = mg1.Text + vbCrLf + strCaseTitle
mg1.Text = mg1.Text + vbCrLf + "Taken By:" + strTakenBy
mg1.Text = mg1.Text + vbCrLf + "Description:"
' mg1.Text = mg1.Text + vbCrLf + "width=" + CStr(shapePicture.Width) + " height " + CStr(shapePicture.Height)
' mg1.Text = mg1.Text + vbCrLf + "Percentage used = " + CStr(dblPercentWidth)
mg1.Text = mg1.Text + vbCrLf & vbCrLf
Next vItem
End If
End With
Set fd = Nothing
End Sub
' AKInsertImages
Sub AKInsertImages()
' v2 31 December 2014
Dim doc As Word.Document
Dim fd As FileDialog
Dim vItem As Variant
Dim mg1 As Range
Dim mg2 As Range
Dim intCount As Integer
Dim strTotal As String
strTotal = ""
intCount = 0
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set doc = ActiveDocument
Dim shapePicture As InlineShape
Dim intSetWidth As Integer
Dim intSetHeight As Integer
' **************************************
intSetWidth = 375
intSetHeight = 400
' **************************************
Dim dblPercentResize As Double
dblPercentResize = 1
' **************************************
' Get Title, Description, Taken By
' **************************************
' eg
' Bicycle Robbery 13 November 2014.
' Taken By: Detective MCGILL. Image: 9 of 9
' Desc:
Dim strCaseTitle As String
Dim strTakenBy As String
strCaseTitle = InputBox("Case Title", "Please enter case title")
strTakenBy = InputBox("Photographed By", "Please enter who took the photo")
With fd
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1
.FilterIndex = 1
If .Show = -1 Then
For Each vItem In .SelectedItems
intCount = intCount + 1
Set mg2 = ActiveDocument.Range
mg2.Collapse wdCollapseEnd
Set shapePicture = doc.InlineShapes.AddPicture( _
FileName:=vItem, _
LinkToFile:=False, SaveWithDocument:=True, Range:=mg2)
' if we are wider than we want, resize percentage
If shapePicture.Width > intSetWidth Then
dblPercentResize = CDbl(intSetWidth / shapePicture.Width)
shapePicture.Width = shapePicture.Width * dblPercentResize
shapePicture.Height = shapePicture.Height * dblPercentResize
End If
' if we are higher than we want, resize percentage
If shapePicture.Height > intSetHeight Then
dblPercentResize = CDbl(intSetHeight / shapePicture.Height)
shapePicture.Width = shapePicture.Width * dblPercentResize
shapePicture.Height = shapePicture.Height * dblPercentResize
End If ' height
Set mg1 = ActiveDocument.Range
mg1.Collapse wdCollapseEnd
strTotal = CStr(.SelectedItems.Count)
mg1.Text = ""
mg1.Text = vbCrLf + "Image: " + CStr(intCount) + " of " + strTotal
mg1.Text = mg1.Text + vbCrLf + strCaseTitle
mg1.Text = mg1.Text + vbCrLf + "Taken By:" + strTakenBy
mg1.Text = mg1.Text + vbCrLf + "Description:"
' mg1.Text = mg1.Text + vbCrLf + "width=" + CStr(shapePicture.Width) + " height " + CStr(shapePicture.Height)
' mg1.Text = mg1.Text + vbCrLf + "Percentage used = " + CStr(dblPercentWidth)
mg1.Text = mg1.Text + vbCrLf & vbCrLf
Next vItem
End If
End With
Set fd = Nothing
End Sub
' AKInsertImages
Monday, 7 March 2011
Drupal and Php - Create content from code part 2 of 2
<?php
$xmlstr = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<meadinkent>
<staff>
<surname>Abejian</surname>
<first_name>Gary</first_name>
<position>Hellenic Village Maintenance </position>
<phone_number>85432010</phone_number>
<extension_number></extension_number>
<fax_number>95255044</fax_number>
<mobile>0406383053</mobile>
<email>gabejian@stbasils.org.au</email>
</staff>
<staff>
<surname>Alexopoulos</surname>
<first_name>Despina</first_name>
<position>Nursing Home - Deputy Director of Nursing</position>
<phone_number>97843233</phone_number>
<extension_number>x3233</extension_number>
<fax_number>97580366</fax_number>
<mobile>0406380379</mobile>
<email>dalexopoulos@stbasils.org.au</email>
</staff>
$xmlstr = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<meadinkent>
<staff>
<surname>Abejian</surname>
<first_name>Gary</first_name>
<position>Hellenic Village Maintenance </position>
<phone_number>85432010</phone_number>
<extension_number></extension_number>
<fax_number>95255044</fax_number>
<mobile>0406383053</mobile>
<email>gabejian@stbasils.org.au</email>
</staff>
<staff>
<surname>Alexopoulos</surname>
<first_name>Despina</first_name>
<position>Nursing Home - Deputy Director of Nursing</position>
<phone_number>97843233</phone_number>
<extension_number>x3233</extension_number>
<fax_number>97580366</fax_number>
<mobile>0406380379</mobile>
<email>dalexopoulos@stbasils.org.au</email>
</staff>
Drupal and Php - Create content from code part 1 of 2
// and at least an element /[root]/title.
echo "a";
include 'staff2011a.php';
$xml = new SimpleXMLElement($xmlstr);
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT.'/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Import node functions.
module_load_include('inc', 'node', 'node.pages');
echo "1";
global $user; //get current logged in user
echo "2";
/* For each
foreach ($xml->staff as $arecord) {
echo $arecord->surname, ' played by ', $arecord->surname, PHP_EOL, "
";
$new_node = new stdClass();
$new_node->type = 'staff';
$new_node->uid = $user->uid; //you can specify some other userID here if you want
$new_node->name = $user->name;
$new_node->title = $arecord->first_name.' '.$arecord->surname;
$new_node->body = '';
$new_node->status = 1; // published
$new_node->field_extension[0]['value'] = $arecord->extension_number;
$new_node->field_mobile[0]['value'] = $arecord->mobile;
$new_node->field_phone[0]['value'] = $arecord->phone_number;
$new_node->field_email[0]['value'] = $arecord->email;
$new_node->field_position[0]['value'] = $arecord->position;
$new_node->field_fax[0]['value'] = $arecord->fax_number;
node_save($new_node);
echo "3";
} // end foreach
echo "b";
echo "4";
?>
Create XML from excel
This is not my work, but is from the website:http://www.meadinkent.co.uk/xl_xml1.htm
Sub MakeXML()
' create an XML file from an Excel table
Dim MyRow As Integer, MyCol As Integer, Temp As String, YesNo As Variant, DefFolder As String
Dim XMLFileName As String, XMLRecSetName As String, MyLF As String, RTC1 As Integer
Dim RangeOne As String, RangeTwo As String, Tt As String, FldName(99) As String
MyLF = Chr(10) & Chr(13) ' a line feed command
DefFolder = "C:\" 'change this to the location of saved XML files
YesNo = MsgBox("This procedure requires the following data:" & MyLF _
& "1 A filename for the XML file" & MyLF _
& "2 A groupname for an XML record" & MyLF _
& "3 A cellrange containing fieldnames (col titles)" & MyLF _
& "4 A cellrange containing the data table" & MyLF _
& "Are you ready to proceed?", vbQuestion + vbYesNo, "MakeXML CiM")
If YesNo = vbNo Then
Debug.Print "User aborted with 'No'"
Exit Sub
End If
XMLFileName = FillSpaces(InputBox("1. Enter the name of the XML file:", "MakeXML CiM", "xl_xml_data"))
If Right(XMLFileName, 4) <> ".xml" Then
XMLFileName = XMLFileName & ".xml"
End If
XMLRecSetName = FillSpaces(InputBox("2. Enter an identifying name of a record:", "MakeXML CiM", "record"))
RangeOne = InputBox("3. Enter the range of cells containing the field names (or column titles):", "MakeXML CiM", "A3:D3")
If MyRng(RangeOne, 1) <> MyRng(RangeOne, 2) Then
MsgBox "Error: names must be on a single row" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
MyRow = MyRng(RangeOne, 1)
For MyCol = MyRng(RangeOne, 3) To MyRng(RangeOne, 4)
If Len(Cells(MyRow, MyCol).Value) = 0 Then
MsgBox "Error: names range contains blank cell" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
FldName(MyCol - MyRng(RangeOne, 3)) = FillSpaces(Cells(MyRow, MyCol).Value)
Next MyCol
RangeTwo = InputBox("4. Enter the range of cells containing the data table:", "MakeXML CiM", "A4:D8")
If MyRng(RangeOne, 4) - MyRng(RangeOne, 3) <> MyRng(RangeTwo, 4) - MyRng(RangeTwo, 3) Then
MsgBox "Error: number of field names <> data columns" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
RTC1 = MyRng(RangeTwo, 3)
If InStr(1, XMLFileName, ":\") = 0 Then
XMLFileName = DefFolder & XMLFileName
End If
Open XMLFileName For Output As #1
Print #1, ""
Print #1, ""
For MyRow = MyRng(RangeTwo, 1) To MyRng(RangeTwo, 2)
Print #1, "<" & XMLRecSetName & ">"
For MyCol = RTC1 To MyRng(RangeTwo, 4)
' the next line uses the FormChk function to format dates and numbers
Print #1, "<" & FldName(MyCol - RTC1) & ">" & RemoveAmpersands(FormChk(MyRow, MyCol)) & "" & FldName(MyCol - RTC1) & ">"
' the next line does not apply any formatting
' Print #1, "<" & FldName(MyCol - RTC1) & ">" & RemoveAmpersands(Cells(MyRow, MyCol).Value) & "" & FldName(MyCol - RTC1) & ">"
Next MyCol
Print #1, "" & XMLRecSetName & ">"
Next MyRow
Print #1, " "
Close #1
MsgBox XMLFileName & " created." & MyLF & "Process finished", vbOKOnly + vbInformation, "MakeXML CiM"
Debug.Print XMLFileName & " saved"
End Sub
Function MyRng(MyRangeAsText As String, MyItem As Integer) As Integer
' analyse a range, where MyItem represents 1=TR, 2=BR, 3=LHC, 4=RHC
Dim UserRange As Range
Set UserRange = Range(MyRangeAsText)
Select Case MyItem
Case 1
MyRng = UserRange.Row
Case 2
MyRng = UserRange.Row + UserRange.Rows.Count - 1
Case 3
MyRng = UserRange.Column
Case 4
MyRng = UserRange.Columns(UserRange.Columns.Count).Column
End Select
Exit Function
End Function
Function FillSpaces(AnyStr As String) As String
' remove any spaces and replace with underscore character
Dim MyPos As Integer
MyPos = InStr(1, AnyStr, " ")
Do While MyPos > 0
Mid(AnyStr, MyPos, 1) = "_"
MyPos = InStr(1, AnyStr, " ")
Loop
FillSpaces = LCase(AnyStr)
End Function
Function FormChk(RowNum As Integer, ColNum As Integer) As String
' formats numeric and date cell values to comma 000's and DD MMM YY
FormChk = Cells(RowNum, ColNum).Value
If IsNumeric(Cells(RowNum, ColNum).Value) Then
'atk all my colums are text. remove this line FormChk = Format(Cells(RowNum, ColNum).Value, "#,##0 ;(#,##0)")
End If
If IsDate(Cells(RowNum, ColNum).Value) Then
FormChk = Format(Cells(RowNum, ColNum).Value, "dd mmm yy")
End If
End Function
Function RemoveAmpersands(AnyStr As String) As String
Dim MyPos As Integer
' replace Ampersands (&) with plus symbols (+)
MyPos = InStr(1, AnyStr, "&")
Do While MyPos > 0
Mid(AnyStr, MyPos, 1) = "+"
MyPos = InStr(1, AnyStr, "&")
Loop
RemoveAmpersands = AnyStr
End Function
Sub MakeXML()
' create an XML file from an Excel table
Dim MyRow As Integer, MyCol As Integer, Temp As String, YesNo As Variant, DefFolder As String
Dim XMLFileName As String, XMLRecSetName As String, MyLF As String, RTC1 As Integer
Dim RangeOne As String, RangeTwo As String, Tt As String, FldName(99) As String
MyLF = Chr(10) & Chr(13) ' a line feed command
DefFolder = "C:\" 'change this to the location of saved XML files
YesNo = MsgBox("This procedure requires the following data:" & MyLF _
& "1 A filename for the XML file" & MyLF _
& "2 A groupname for an XML record" & MyLF _
& "3 A cellrange containing fieldnames (col titles)" & MyLF _
& "4 A cellrange containing the data table" & MyLF _
& "Are you ready to proceed?", vbQuestion + vbYesNo, "MakeXML CiM")
If YesNo = vbNo Then
Debug.Print "User aborted with 'No'"
Exit Sub
End If
XMLFileName = FillSpaces(InputBox("1. Enter the name of the XML file:", "MakeXML CiM", "xl_xml_data"))
If Right(XMLFileName, 4) <> ".xml" Then
XMLFileName = XMLFileName & ".xml"
End If
XMLRecSetName = FillSpaces(InputBox("2. Enter an identifying name of a record:", "MakeXML CiM", "record"))
RangeOne = InputBox("3. Enter the range of cells containing the field names (or column titles):", "MakeXML CiM", "A3:D3")
If MyRng(RangeOne, 1) <> MyRng(RangeOne, 2) Then
MsgBox "Error: names must be on a single row" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
MyRow = MyRng(RangeOne, 1)
For MyCol = MyRng(RangeOne, 3) To MyRng(RangeOne, 4)
If Len(Cells(MyRow, MyCol).Value) = 0 Then
MsgBox "Error: names range contains blank cell" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
FldName(MyCol - MyRng(RangeOne, 3)) = FillSpaces(Cells(MyRow, MyCol).Value)
Next MyCol
RangeTwo = InputBox("4. Enter the range of cells containing the data table:", "MakeXML CiM", "A4:D8")
If MyRng(RangeOne, 4) - MyRng(RangeOne, 3) <> MyRng(RangeTwo, 4) - MyRng(RangeTwo, 3) Then
MsgBox "Error: number of field names <> data columns" & MyLF & "Procedure STOPPED", vbOKOnly + vbCritical, "MakeXML CiM"
Exit Sub
End If
RTC1 = MyRng(RangeTwo, 3)
If InStr(1, XMLFileName, ":\") = 0 Then
XMLFileName = DefFolder & XMLFileName
End If
Open XMLFileName For Output As #1
Print #1, ""
Print #1, "
For MyRow = MyRng(RangeTwo, 1) To MyRng(RangeTwo, 2)
Print #1, "<" & XMLRecSetName & ">"
For MyCol = RTC1 To MyRng(RangeTwo, 4)
' the next line uses the FormChk function to format dates and numbers
Print #1, "<" & FldName(MyCol - RTC1) & ">" & RemoveAmpersands(FormChk(MyRow, MyCol)) & "" & FldName(MyCol - RTC1) & ">"
' the next line does not apply any formatting
' Print #1, "<" & FldName(MyCol - RTC1) & ">" & RemoveAmpersands(Cells(MyRow, MyCol).Value) & "" & FldName(MyCol - RTC1) & ">"
Next MyCol
Print #1, "" & XMLRecSetName & ">"
Next MyRow
Print #1, "
Close #1
MsgBox XMLFileName & " created." & MyLF & "Process finished", vbOKOnly + vbInformation, "MakeXML CiM"
Debug.Print XMLFileName & " saved"
End Sub
Function MyRng(MyRangeAsText As String, MyItem As Integer) As Integer
' analyse a range, where MyItem represents 1=TR, 2=BR, 3=LHC, 4=RHC
Dim UserRange As Range
Set UserRange = Range(MyRangeAsText)
Select Case MyItem
Case 1
MyRng = UserRange.Row
Case 2
MyRng = UserRange.Row + UserRange.Rows.Count - 1
Case 3
MyRng = UserRange.Column
Case 4
MyRng = UserRange.Columns(UserRange.Columns.Count).Column
End Select
Exit Function
End Function
Function FillSpaces(AnyStr As String) As String
' remove any spaces and replace with underscore character
Dim MyPos As Integer
MyPos = InStr(1, AnyStr, " ")
Do While MyPos > 0
Mid(AnyStr, MyPos, 1) = "_"
MyPos = InStr(1, AnyStr, " ")
Loop
FillSpaces = LCase(AnyStr)
End Function
Function FormChk(RowNum As Integer, ColNum As Integer) As String
' formats numeric and date cell values to comma 000's and DD MMM YY
FormChk = Cells(RowNum, ColNum).Value
If IsNumeric(Cells(RowNum, ColNum).Value) Then
'atk all my colums are text. remove this line FormChk = Format(Cells(RowNum, ColNum).Value, "#,##0 ;(#,##0)")
End If
If IsDate(Cells(RowNum, ColNum).Value) Then
FormChk = Format(Cells(RowNum, ColNum).Value, "dd mmm yy")
End If
End Function
Function RemoveAmpersands(AnyStr As String) As String
Dim MyPos As Integer
' replace Ampersands (&) with plus symbols (+)
MyPos = InStr(1, AnyStr, "&")
Do While MyPos > 0
Mid(AnyStr, MyPos, 1) = "+"
MyPos = InStr(1, AnyStr, "&")
Loop
RemoveAmpersands = AnyStr
End Function
Tuesday, 21 December 2010
Break Reminder/Stretch Program
http://sourceforge.net/projects/workrave/files/workrave/1.9.3/workrave-win32-v1.9.3-installer.exe/download
Sunday, 5 December 2010
Code to sort your Linux downloads directory. I run this every day.
#!/bin/bash
# Set these two variables to the full pathname
# of your holding and storage directories
downloads=/home/akendrick451/Downloads
cd $downloads
#make sure we have our directories created
mkdir -p Music
mkdir -p Zips
mkdir -p Applications
mkdir -p Documents
mkdir -p Images
mkdir -p Scripts
mkdir -p Other
ls | while read file
do
filetype=$(file -ib "$file")
#echo $file $filetype
# echo "$filetype"
if [ "$filetype" = "application/octet-stream; charset=binary" ]; then
echo "music" $file $filetype
blMove=true
strFolder="Music"
elif [ "$filetype" = "application/x-directory; charset=binary" ]; then
blMove=false
elif [ "$filetype" = "application/zip; charset=binary" ]; then
blMove=true
strFolder="Zips"
elif [ "$filetype" = "application/x-gzip; charset=binary" ]; then
blMove=true
strFolder="Zips"
elif [ "$filetype" = "application/x-bzip2; charset=binary" ]; then
blMove=true
strFolder="Zips"
elif [ "$filetype" = "image/jpeg; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "image/png; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "image/x-ico; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "image/gif; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "application/pdf; charset=binary" ]; then
blMove=true
strFolder="Documents"
elif [ "$filetype" = "text/html; charset=utf-8" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "text/plain; charset=us-ascii" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "application/msword; charset=binary" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "application/vnd.oasis.opendocument.text; charset=binary" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "text/html; charset=us-ascii" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "text/x-shellscript; charset=us-ascii" ]; then
strFolder="Scripts"
blMove=true
elif [ "$filetype" = "text/x-php; charset=us-ascii" ]; then
strFolder="Scripts"
blMove=true
elif [ "$filetype" = "application/vnd.ms-office; charset=binary" ]; then
blMove=true
strFolder="Documents"
else
blMove=true
strFolder="Other"
#echo "doc?" $file $filetype
fi
if [ $blMove = true ]; then
echo Moving... $file to $strFolder
blMove=false
mv "$file" $strFolder/"$file"
fi
done
# Set these two variables to the full pathname
# of your holding and storage directories
downloads=/home/akendrick451/Downloads
cd $downloads
#make sure we have our directories created
mkdir -p Music
mkdir -p Zips
mkdir -p Applications
mkdir -p Documents
mkdir -p Images
mkdir -p Scripts
mkdir -p Other
ls | while read file
do
filetype=$(file -ib "$file")
#echo $file $filetype
# echo "$filetype"
if [ "$filetype" = "application/octet-stream; charset=binary" ]; then
echo "music" $file $filetype
blMove=true
strFolder="Music"
elif [ "$filetype" = "application/x-directory; charset=binary" ]; then
blMove=false
elif [ "$filetype" = "application/zip; charset=binary" ]; then
blMove=true
strFolder="Zips"
elif [ "$filetype" = "application/x-gzip; charset=binary" ]; then
blMove=true
strFolder="Zips"
elif [ "$filetype" = "application/x-bzip2; charset=binary" ]; then
blMove=true
strFolder="Zips"
elif [ "$filetype" = "image/jpeg; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "image/png; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "image/x-ico; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "image/gif; charset=binary" ]; then
blMove=true
strFolder="Images"
elif [ "$filetype" = "application/pdf; charset=binary" ]; then
blMove=true
strFolder="Documents"
elif [ "$filetype" = "text/html; charset=utf-8" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "text/plain; charset=us-ascii" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "application/msword; charset=binary" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "application/vnd.oasis.opendocument.text; charset=binary" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "text/html; charset=us-ascii" ]; then
strFolder="Documents"
blMove=true
elif [ "$filetype" = "text/x-shellscript; charset=us-ascii" ]; then
strFolder="Scripts"
blMove=true
elif [ "$filetype" = "text/x-php; charset=us-ascii" ]; then
strFolder="Scripts"
blMove=true
elif [ "$filetype" = "application/vnd.ms-office; charset=binary" ]; then
blMove=true
strFolder="Documents"
else
blMove=true
strFolder="Other"
#echo "doc?" $file $filetype
fi
if [ $blMove = true ]; then
echo Moving... $file to $strFolder
blMove=false
mv "$file" $strFolder/"$file"
fi
done
Thursday, 28 October 2010
Diagnosing linux problems using strace....
from : http://www.serverwatch.com/tutorials/article.php/3909856/Using-Strace-to-Trace-Problems.htm
Using Strace to Trace Problems
October 25, 2010
By Joe Brockmeier
Having trouble figuring out why Apache isn't starting, or another program is crashing and burning, and the logfiles are giving no clue? Time to reach for strace.
What's strace? The strace utility is used to run a command and display its system calls, so you can see exactly what the program is doing until it exits. Experienced users can work with strace to do performance testing and so on, but even beginners can use strace as a diagnostic tool to see why a program is crashing.
Here's what you do. First, simply start your application or service using Strace, like so:
strace commandname
Using Strace to Trace Problems
October 25, 2010
By Joe Brockmeier
Having trouble figuring out why Apache isn't starting, or another program is crashing and burning, and the logfiles are giving no clue? Time to reach for strace.
What's strace? The strace utility is used to run a command and display its system calls, so you can see exactly what the program is doing until it exits. Experienced users can work with strace to do performance testing and so on, but even beginners can use strace as a diagnostic tool to see why a program is crashing.
Here's what you do. First, simply start your application or service using Strace, like so:
strace commandname
Friday, 27 August 2010
Thursday, 29 October 2009
Android Apps - For Sydney, Australia, Catholic, Tech
Mind Mapping
http://www.androlib.com/android.application.net-thinkingspace-jFDx.aspx
http://www.androlib.com/android.application.net-thinkingspace-jFDx.aspx
Wednesday, 15 July 2009
Sunday, 15 February 2009
Wednesday, 21 January 2009
Wednesday, 17 September 2008
How to not Install programs in Ubuntu
You have downloaded a linux program and double click to install it, and it shows up in a unzip program. What to do? After some foraging around I have the answer.
Note, you can always use the Add/Remove programs from Ubuntu menus or you can use the Synaptic package manager. I know that, but I have a file on my desktop, perhaps a .tar.gz file, or I have unzipped it and I have a folder on my desktop. What now?
Coming from a Windows background, I would download a file and click on it to install.
Just now, I tried to install the Calendar program from Mozilla. I was smart enough to realise that I needed to download the Linux version, but was confused for a time what i86 meant next to it.
A file downloaded as a .tar.gz is a zip file and will need to be unzipped before you can use it. Think of .tar.gz as the shrinkwrap packaging, you need to unwrap it first to get at it.
You can unzip it usually using the mouse and right clicking.
Step2. Decide if it is ready to use or needs a bit of setting up.
Sometimes software comes already set up and ready to go, or it's in in a flat packed box with screws and bits of wood, and you have to set it up yourself.
One way to decide if it's ready to use is to find the folder that we unzipped to, open the folder. I was installing a sunbird application, so I clicked on a file names Sunbird. The computer asked if I wanted to run it or run it in a command window. I said run it - I was proud.
But nothing happened. So I thought, it needs a bit of putting together.
Step 2a) Put it Together
======================
STOP the press.
Guys, I tried to work this out, but could not. My advice is to use the Add/Update manager via the Applications menu in Ubuntu.
Ubuntu 1, Anthony 0
Note, you can always use the Add/Remove programs from Ubuntu menus or you can use the Synaptic package manager. I know that, but I have a file on my desktop, perhaps a .tar.gz file, or I have unzipped it and I have a folder on my desktop. What now?
Coming from a Windows background, I would download a file and click on it to install.
Just now, I tried to install the Calendar program from Mozilla. I was smart enough to realise that I needed to download the Linux version, but was confused for a time what i86 meant next to it.
A file downloaded as a .tar.gz is a zip file and will need to be unzipped before you can use it. Think of .tar.gz as the shrinkwrap packaging, you need to unwrap it first to get at it.
You can unzip it usually using the mouse and right clicking.
Step2. Decide if it is ready to use or needs a bit of setting up.
Sometimes software comes already set up and ready to go, or it's in in a flat packed box with screws and bits of wood, and you have to set it up yourself.
One way to decide if it's ready to use is to find the folder that we unzipped to, open the folder. I was installing a sunbird application, so I clicked on a file names Sunbird. The computer asked if I wanted to run it or run it in a command window. I said run it - I was proud.
But nothing happened. So I thought, it needs a bit of putting together.
Step 2a) Put it Together
======================
STOP the press.
Guys, I tried to work this out, but could not. My advice is to use the Add/Update manager via the Applications menu in Ubuntu.
Ubuntu 1, Anthony 0
Monday, 1 September 2008
Nice find files program similiar to search
http://www.locate32.net/
Great little program. Ultra fast, and it find what I want on my computer!
Great little program. Ultra fast, and it find what I want on my computer!
Subscribe to:
Posts (Atom)