Postcode Programming API PostTrans XL Visual Importer: Extra Functions and VBA Code


The functionality of PostTrans can be enhanced by using functions and VBA code listed below.

PostTrans Add the following functions:


Extra Functions provided by PostTrans:


PostTrans provides the following extra user-functions (similar to EntFuncs.xla):

Rounding Values using Exchequer Rounding

This function allows you to use the rounding as applied in Enterprise

Public Function ZEntRound(Value#, DecimalPlaces&) As Double

'   Round value using Enterprise rounding to x Places

Extracting single lines from Memo fields

Function that extracts a single line of text from Memo fields

Public Function ZEntGetLine(TextMemo As Variant, LineNo%, Optional BreakChr$ = "")

'   Extract a single line from text (line%)

'   Where BreakChr$ is used to identify the end of the line

'       Defaults the chr$(10)

For Example:

= ZEntGetLine (C4,1)

Will return line one of a memo field (Multiple line data) contained in cell C4. 

Stripping Hidden Characters from text

PostTrans trims each text field before importing.  It may be necessary to strip hidden characters out of text occasionally.

Public Function ZEntStripHidden(Text$) As String

'   Strips hidden chars out of text (Anything less than Chr$(32)

Removing a code from Lookup value

It may be necessary to remove a code from a look value.

For Example:

AAA, MAIN Location

A function is provided to strip "AAA" from the above:

Public Function ZExtractCode(Text)

 

Importing many different types of data into Exchequer Enterprise :


One spread sheet can be made to activate many others using macros.  So the user can fill in one sheet with information then press one button to create a stock item, create a new account, and then post a sales order.

Posting multiple sheets using VBA code

The following post two sheets from a single button.

Function PostTransactions()
    ' Post Transactions in CustomerOrderPad and SupplierOrderPad sheet
    Dim CustomerPostedOK%, SupplierPostedOK%

    'Post Transaction
    CustomerPostedOK = PostCustomerOrder()
    SupplierPostedOK = PostSupplierOrder()

    Sheets("CustomerOrderPad").Select

    If CustomerPostedOK And SupplierPostedOK Then
        MsgBox "Finished!"
    Else
        MsgBox "Error occured in ons sheet!"
    End If
End Function

Function PostCustomerOrder()
    Sheets("CustomerOrderPad").Select

    Application.Run macro:="PostTransaction"

    If HasOrderPosted() Then
        'Have Posted OK
        PostCustomerOrder = True
    Else
        MsgBox "Sales side has not posed due to an error. Please resolve and try again!"
    End If
End Function


Function PostSupplierOrder()
    Sheets("SupplierOrderPad").Select

    Application.Run macro:="PostTransaction"

    If HasOrderPosted() Then
        'Have Posted OK
        PostSupplierOrder = True
    Else
        MsgBox "Purchase side has not posed due to an error. Please resolve and try again!"
    End If
End Function


Function HasOrderPosted() As boolean
    ' Return true if posted

    HasOrderPosted = Left$(ActiveSheet.Range("A20").Value, 6) = "POSTED"
End Function



Posting new customer, Job and then SOR

Example "SOR with Job and Cust create.xlsm" contains a button which will first post a customer, then Job, and finally a SOR.