tempFiltersArray = xlApp.Application.Run("SAPListOfEffectiveFilters", thedatasource, "INPUT_STRING")
tempFiltersArray = xlApp.Application.Run("SAPListOfDynamicFilters", thedatasource, "INPUT_STRING")
Private Sub Send_Email_CDO(therecipient As String, thesubject As String, thebody As String, _
theattachment As String)
' This code is from http://www.rondebruin.nl/win/s1/cdo.htm
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = CDO_Server
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Update
End With
With iMsg
Set .Configuration = iConf
.to = therecipient
.CC = ""
.BCC = ""
.From = "sendersaddress@example.com"
.Subject = thesubject
.TextBody = thebody
.AddAttachment theattachment
.Send
End With
End Sub
Public Function NumberOfArrayDimensions(arr As Variant) As Integer
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' NumberOfArrayDimensions
' This function returns the number of dimensions of an array. An unallocated dynamic array
' has 0 dimensions. This condition can also be tested with IsArrayEmpty.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Ndx As Integer
Dim Res As Integer
On Error Resume Next
' Loop, increasing the dimension index Ndx, until an error occurs.
' An error will occur when Ndx exceeds the number of dimension
' in the array. Return Ndx - 1.
Do
Ndx = Ndx + 1
Res = UBound(arr, Ndx)
Loop Until Err.Number <> 0
NumberOfArrayDimensions = Ndx - 1
End Function
Dim NumberOfDimensions as Integer
array_start = 1
array_end = Application.CountA(tempVariablesArray) / 2
If array_end = 1 Then
' We have only 1 real record, so we know VariablesArray is ONE dimensional
techname = xlApp.Application.Run("SAPGetVariable", thedatasource, tempVariablesArray(1), "TECHNICALNAME")
VariablesArray(UBound(VariablesArray)) = techname
Else
' We have more than 1 record, so we know VariablesArray is TWO dimensional
For arrayloop = array_start To array_end
techname = xlApp.Application.Run("SAPGetVariable", thedatasource, tempVariablesArray(arrayloop, 1), "TECHNICALNAME")
VariablesArray(UBound(VariablesArray)) = techname
Next arrayloop
End If
NumberOfDimensions = NumberOfArrayDimensions(tempVariablesArray)
If NumberOfDimensions = 1 Then
' We have only 1 real record, so we know VariablesArray is ONE dimensional
techname = xlApp.Application.Run("SAPGetVariable", thedatasource, tempVariablesArray(1), "TECHNICALNAME")
VariablesArray(UBound(VariablesArray)) = techname
Else
' We have more than 1 record, so we know VariablesArray is TWO dimensional
For arrayloop = LBound(tempVariablesArray) To UBound(tempVariablesArray)
techname = xlApp.Application.Run("SAPGetVariable", thedatasource, tempVariablesArray(arrayloop, 1), "TECHNICALNAME")
VariablesArray(UBound(VariablesArray)) = techname
Next arrayloop
End If
1. Save the whole file to a temporary filename.
2. Load the new file and delete any sheet on it that isn't the sheet we want.
3. Save and/or email the new file.
xlApp.ActiveWorkbook.RefreshAll
TODAY : Today date. Format DD.MM.YYYY
YESTERDAY : Yesterdays date. Format DD.MM.YYYY
CURRENTDAY : Todays date, but just the day. Format DD
CURRENTMONTH : Current Calendar Month. Format MM.YYYY
CURRENTYEAR : Current Calendar Year. Format YYYY
LASTMONTH : Previous Calendar Month when compared to today. Format MM.YYYY. Same as PREVIOUSCALENDARMONTH.
ENDOFLASTMONTH : The date of the final day of the previous calendar month. Format DD.MM.YYYY
PREVIOUSCALENDARWEEK : The calendar week number for last week. Based on a week starting on Mondays. Format WW.YYYY
PREVIOUSCALENDARWEEKLASTYEAR : Same as PREVIOUSCALENDARWEEK but for the previous year. Format WW.YYYY
PREVIOUSCALENDARMONTH : Same as LASTMONTH. Format MM.YYYY
PREVIOUSCALENDARMONTHLASTYEAR : Same as PREVIOUSCALENDARMONTH but for the previous year. Format MM.YYYY
LASTSUNDAY : The date of the most recent sunday. Format DD.MM.YYYY
LASTSUNDAYLASTYEAR : Same as LASTSUNDAY but for the previous year. Format DD.MM.YYYY
FINANCIALYEAR : The current Fiscal year. Format YYYY.
FIRSTDAYOFFINANCIALYEAR : First day of the current financial year (assuming a July to June financial year). Format DD.MM.YYYY
FIRSTDAYOFFINANCIALYEARLASTYEAR : Same as FIRSTDAYOFFINANCIALYEAR but for the previous year. Format DD.MM.YYYY
I needed to get current Year to Date figures, but to the end of the most recent week (week finishing on a Sunday). Then needed to also compare that with the same for the previous financial year.
I can't use Calendar weeks for this as one of the weeks begins before the start of the financial year.
Instead I used the variables in the parameter file as follows :
FIRSTDAYOFFINANCIALYEAR - LASTSUNDAY; FIRSTDAYOFFINANCIALYEARLASTYEAR - LASTSUNDAYLASTYEAR
The VBA code converts this to :
01.07.2016 - 19.02.2017; 01.07.2015 - 19.02.2016
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |