I have an application deployed in the development server (notes client). The application composed a function to export the data in the local machine of the user along with the graph generation. My problem is, when the data are exported, the rendering of graph is incorrect (in the server), but when I run it in my local machine the graph rendering is fine.
I used MS 2007 in my local machine but in the development server there is NO MS Office installed.Is there any way to do this? Here is the code below.
Dim s As New notessession
Dim db As notesdatabase
Set db= s.currentdatabase
Dim uiw As New NotesUIWorkspace
Dim otherdoc As NotesDocument
Dim otherview As NotesView
Dim othercol As NotesDocumentCollection
Dim ViewNav As NotesViewNavigator
Dim entry As notesViewEntry
Dim tempdoc As notesdocument
Dim uiv As notesuiview
Set uiv = uiw.currentview
Dim VName As String
VName = uiv.ViewName
'if it is R4 then viewalias doesn't work so use
'environment variable stashed in the post open event
If Instr(s.Notesversion, "Release 4") Then
currentviewname = s.getenvironmentstring("Tracking")
If currentviewname="" Then
Msgbox "View not exist."
End
End If
Call s.setenvironmentvar("Tracking","")
Elseif uiv.viewalias <> "" Then 'use alias if it isn't blank
currentviewname = uiv.viewalias
Else ' use name
currentviewname = uiv.viewname
End If
'Get the view
Set otherview = db.GetView(currentviewname)
If otherview Is Nothing Then
Messagebox "Could not open the view. """ & currentviewname & """"
Exit Sub
End If
'Check if it is for all documents or only selected
Set othercol = db.unprocesseddocuments
If othercol.count >1 Then 'if more than one doc selected then confirm
resp = Messagebox("Do you want to export only the " & _
"selected " & othercol.count & " documents?", 36, "Selected only?" )
If resp=6 Then
Else
Exit Sub
End If
Else
Messagebox "Exporting all rows. (To export only selected " & _
"rows tick those required in the left margin first.)"
End If '6= yes
Dim object As NotesEmbeddedObject
Dim xlApp As Variant
Dim oWorkbook As Variant
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True 'set to visible, this can be moved to the end if you wish
Set oworkbook = xlApp.Workbooks 'handle to Workbook
oworkbook.Add
'Stick out the column headers
hcolmn=1
Forall c In otherview.Columns
xlApp.cells(1,hcolmn) = c.title
hcolmn=hcolmn+1
End Forall
row=2
Dim vc As NotesViewEntryCollection
Dim seldoc As notesdocument
Dim view As notesview
Set view = db.GetView(VName)
Set vc = view.AllEntries
If resp=6 Then
Set seldoc = othercol.GetFirstDocument
While Not seldoc Is Nothing
Set entry = vc.GetEntry(selDoc)
Print "Entry " entry.noteID " from document " selDoc.noteID '<--- new line
'Msgbox row
For colmn = 0 To Ubound(entry.ColumnValues)
col% = col% + 1
xlApp.cells(row,colmn+1) = entry.columnvalues(colmn)
Next
row=row+1
Set seldoc = othercol.GetNextDocument(seldoc)
Wend
Else ' all documents
Set otherdoc = otherview.GetFirstDocument
While Not otherdoc Is Nothing
For colmn = 0 To Ubound(otherview.Columns)
xlApp.cells(row,colmn+1) = otherdoc.columnvalues(colmn)
Next
row=row+1
Set otherdoc = otherview.GetNextDocument(otherdoc)
Wend
End If
'this highlights the headings
xlApp.application.Rows("1:1").Select
With xlApp.application.Selection.Font
.bold = True
.ColorIndex = 48
.Name = "Arial"
.Size = 10
End With
'this freezes the panes
xlApp.application.Rows("2:2").Select
xlApp.application.ActiveWindow.FreezePanes = True
xlChartType = 51
xlapp.ActiveWorkbook.Charts.Add
With xlapp.ActiveWorkbook.ActiveChart
.Name = "Chart"
.HasTitle = True
.ChartTitle.Text = "Total Submissions Received per Month"
.Axes("1").HasTitle = True 'xlCategory = x axis
.Axes("1").AxisTitle.Text = "Month"
.Axes("1").AxisTitle.AutoScaleFont = True
.Axes("1").AxisTitle.Font.Size = 8
.Axes("2").HasTitle = True 'xlValue = y axis
.Axes("2").AxisTitle.Text = "No. of Submission"
.Axes("2").AxisTitle.AutoScaleFont = True
.Axes("2").AxisTitle.Font.Size = 8
.ChartType = xlChartType
.PlotArea.Interior.ColorIndex = "0"
.PlotBy = "1" '2 = Column Plot
.SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N6")
End With
The fact that you instantiate new NotesUIWorkspace means that the agent does not run on the server. So you should probably ask about the version of Excel on the computers of other users, who run the code. Note that the agent would only run on the server if it is scheduled or if you make it run on the server using notesAgent.RunOnServer( [ noteID$ ] ).
I changed this line and it works fine even there is no excel installed on the server.
change SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N6") to SetSourceData xlApp.Worksheets("Sheet1").Range("A1","N" & row-1)
Related
I am tasked with making a database in microsoft access to which we store parts list. The lists gets delivered in the excel format .xls.
This worksheet has a field header fields ( distinct cells with data) and a list a few rows below. I can get the code to work IF currently there is a normally opened excel file, for instance your personal.XLSB. If Excel is not running, i get issues in the form of
:error 429. activeX can not create object.
or at times an Error 462 in VBA :
remote server machine not found,
application starts with: Cmd_Inlezen_Stuklijst_Import_Click
i have tried to create an instance of excel running in the background by testing if excel is running the function IsExcelRunning
Application.ScreenUpdating = False
Dim src As Workbook
' OPEN THE SOURCE EXCEL WORKBOOK IN "READ ONLY MODE".
Set src = Workbooks.Open(Me!TxtFullPath)
src.Close False ' FALSE - DON'T SAVE THE SOURCE FILE.
Set src = Nothing
sometimes this seems toworks, but i haven't been able to determine exactly how.
i LITERALLY copied https://social.msdn.microsoft.com/Forums/en-US/ffd5975b-83fa-4d64-94af-7230f0058a3d/opening-an-excel-file-from-ms-access?forum=isvvba
then changed the path to the file i need, but as long as excel is NOT running, it doesn't work.
instead of CreateObject, I also tried GetObject but same 429 error
The code in the if statement after i check the status of excel is also according to example. ( source no longer known to me)
I have the references turned on Microsoft Excel 14 object library.
'***************************************************************************
'Purpose: check if excel is running 0 als onwaar -1 als waar
'Inputs
'Outputs: boolean
'***************************************************************************
Public Function IsExcelRunning() As Boolean '
Dim xl As Object
On Error Resume Next
Set xl = GetObject(, "Excel.Application")
IsExcelRunning = (Err.Number = 0)
Set xl = Nothing
End Function
'***************************************************************************
'Purpose: pikt de kop gegevens van het formulier op.
'Inputs:
'A2 leeg
'B2 stuklijstNaam
'C2 editie klant
'D2 Editie Debrug
'E2 Stuklijstomschrijving
'F2 creatiedatum
'G2 ontvangstdatum
'H2 werktijd
'I2 Default aantal
'J2 klant naam
'B3 eindproduct
'B3 eindproduct omschrijving
'Outputs: boolean
'***************************************************************************
Function MiscDataFetch() As Boolean 'leest headers
Dim my_xl_app As Object
Dim my_xl_worksheet As Object
Dim my_xl_workbook As Object
Set my_xl_app = CreateObject("Excel.Application")
my_xl_app.UserControl = True
my_xl_app.Visible = False ' yes. I know it's the default
'WasteTime (2)
Set my_xl_workbook = GetObject(Me!TxtFullPath)
'Set my_xl_workbook = CreateObject(Me!TxtFullPath)
Set my_xl_worksheet = my_xl_workbook.Worksheets(1)
Me!FilStuklijstNaam = my_xl_worksheet.Cells(2, "B")
Me!FilEditieKlant = my_xl_worksheet.Cells(2, "C")
Me!FilEditieDeBrug = my_xl_worksheet.Cells(2, "D")
Me!FilStuklijstOmschrijving = my_xl_worksheet.Cells(2, "E")
Me!FilCreatieDatum = my_xl_worksheet.Cells(2, "F")
Me!FilOntvangstDatum = my_xl_worksheet.Cells(2, "G")
Me!FilWerktijd = my_xl_worksheet.Cells(2, "H")
Me!filDefaultAantal = my_xl_worksheet.Cells(2, "I")
Me!FilKlantNaam = my_xl_worksheet.Cells(2, "J")
Me!FilEindpoduct = my_xl_worksheet.Cells(3, "B")
Me!FilEindproductOmschr = my_xl_worksheet.Cells(3, "E")
my_xl_workbook.Close SaveChanges:=False
Set my_xl_app = Nothing
Set my_xl_workbook = Nothing
Set my_xl_worksheet = Nothing
MiscDataFetch = True
End Function
Sub WasteTime(Finish As Long)
Dim NowTick As Long
Dim EndTick As Long
EndTick = GetTickCount + (Finish * 1000)
Do
NowTick = GetTickCount
GetTickCount = GetTickCount + (1)
Loop Until NowTick >= EndTick
End Sub
'***************************************************************************
'Purpose: controleert de kopgegevens
'Inputs
'Outputs: boolean True: alle gegevens voorzien
' False: er zijn velden nieet ingevuld
'***************************************************************************
Function FullMiscDataFetch() As Boolean
FullMiscDataFetch = True
Dim Fullfilled As Integer
If Me!FilStuklijstNaam = "" Then Fullfilled = Fullfilled + 1
If Me!FilEditieKlant = "" Then Fullfilled = Fullfilled + 1
If Me!FilEditieDeBrug = "" Then Fullfilled = Fullfilled + 1
If Me!FilStuklijstOmschrijving = "" Then Fullfilled = Fullfilled + 1
If Me!FilCreatieDatum = "" Then Fullfilled = Fullfilled + 1
If Me!FilOntvangstDatum = "" Then Fullfilled = Fullfilled + 1
If Me!FilWerktijd = "" Then Fullfilled = Fullfilled + 1
If Me!filDefaultAantal = "" Then Fullfilled = Fullfilled + 1
If Me!FilKlantNaam = "" Then Fullfilled = Fullfilled + 1
If Me!FilEindpoduct = "" Then Fullfilled = Fullfilled + 1
If Me!FilEindproductOmschr = "" Then Fullfilled = Fullfilled + 1
If Fullfilled > 1 Then
MsgBox "Niet alle detailvelden bevatten gegevens." & vbCrLf & "Vul de gegevens aan en probeer opnieuw."
FullMiscDataFetch = False
End If
End Function
'***************************************************************************
'Purpose: inleescommando voor deze pagina (Frm_stuklijst_Import).
'Inputs
'Outputs:
'***************************************************************************
Private Sub Cmd_Inlezen_Stuklijst_Import_Click() 'commando voor lijst MET headers
Dim SQLKlantUpdate As String
Dim SQLKlantIDUpdate As String
'DoCmd.RunSQL "DELETE * FROM Tbl_Stuklijst_Import" 'opschonen werkblad
'opschonen
'SubFrm_Tbl_Stuklijst_Import.Requery 'updaten van visueel gegeven lege lijst
If IsExcelRunning Then
Else
'Application.ScreenUpdating = False
'Dim src As Workbook
' OPEN THE SOURCE EXCEL WORKBOOK IN "READ ONLY MODE".
'Set src = Workbooks.Open(Me!TxtFullPath)
'src.Close False ' FALSE - DON'T SAVE THE SOURCE FILE.
'Set src = Nothing
End If
MiscDataFetch 'get header comments
'FetchData 'get material list
FullMiscDataFetch 'controle of alle velden info bevatten
End Sub
expected result is that the distinct cells are read and transferred to fields in the form, whether excel is running or not, and without the need for the user to intervene by activating Excel to bypass the error.
I need to somehow catch the difference in method whether excel is running or not.
Try this to open and close an Excel file:
Dim xl As Excel.Application
Dim xlBook As Excel.workbook
Dim xlSheet As Excel.worksheet
Set xl = New Excel.Application
Set xlBook = xl.Workbooks.Open(Filename)
Set xlSheet = xlBook.Worksheets(1)
…
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
Set xl = Nothing
If you are using types of Excel as in
Dim wb As Excel.Workbook
then you must have a reference to Excel; however, if you are working with Late Binding as in
Dim wb As Object 'Excel.Workbook
Then remove the reference to Excel. This has the advantage that your code will work with different versions of Excel. Otherwise you are tied to a specific version. Often I use early binding (first method) during development and then switch to Object for all library-specific types and remove the reference. This makes the Access application more stable.
I usually use this code to get the application. If the application is open I return it (GetObject), otherwise I create it (CreateObject). Here shown with Word:
Public Function GetWordApplication() As Object
'Gets an active Word application or opens a new Word instance.
'Raises Error No. 8 if word cannot be opened.
On Error Resume Next
'Find existing instance of Word
Set GetWordApplication = GetObject(, "Word.Application")
If Err.Number <> 0 Then 'Not found, create new instance.
Set GetWordApplication = CreateObject("Word.Application")
End If
On Error GoTo 0
If GetWordApplication Is Nothing Then
Err.Raise 8, "YourApp.GetWordApplication", "Word could not be opened."
End If
End Function
I am pasting some excel data into powerpoint as a picture and I am having some issues. I have 290 files which I am pasting a table into slide 4, 5 and 6 of each PP file. This worked perfectly yesterday when I was only doing 1 table into slide 6. I have replicated the process and now I keep getting random errors at random times. Sometimes its file 10, others file 50, different everytime. The errors range from the paste datatype is not available OR the clipboard is empty. I have tried every datatype, pasting as a metafile, as a shape, as a picture, just basic pasting and nothing stops the error. I have no idea! Here is my code: PLEASE HELP !
Sub Update_Site_Report()
'Initiate Variables
Dim objPPT As Object
Dim PPTPrez As Object
Dim FinSlide As Object
Dim AssumSlide As Object
Dim RiskSlide As Object
Dim FinTable As Object
Dim AssumTable As Object
Dim RiskTable As Object
Dim fileNameString As String
Dim PicCount As Long
Dim PicCount1 As Long
Dim PicCount2 As Long
Dim i As Long
Dim fileN As String
Dim Directory As String
'Create and open powerpoint application
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Application.ScreenUpdating = False
'Update site report table from spreadsheet
For i = 2 To 291
Sheet20.Cells(18, 2) = Sheet20.Cells(5, i)
Sheet20.Cells(19, 2) = Sheet20.Cells(6, i)
Sheet20.Cells(20, 2) = Sheet20.Cells(7, i)
Sheet20.Cells(21, 2) = Sheet20.Cells(8, i)
Sheet20.Cells(18, 3) = Sheet20.Cells(10, i)
Sheet20.Cells(19, 3) = Sheet20.Cells(11, i)
Sheet20.Cells(20, 3) = Sheet20.Cells(12, i)
Sheet20.Cells(21, 3) = Sheet20.Cells(13, i)
'Take column header from spreadsheet and set as filename
fileN = Sheet20.Cells(4, i)
' Allow directory to be set in excel tab
Directory = Sheet20.Cells(18, 5)
'Open powerpoint presentation at Directory with Filename
Set PPTPrez = objPPT.Presentations.Open(Directory & fileN & ".pptx")
'Set range for site report table
Set Financials = Sheet20.Range("A17:C21")
Set Assumptions = Sheet45.Range("A1:C7")
Set Risks = Sheet45.Range("A24:D41")
'Choose which slide to paste site report table
Set FinSlide = PPTPrez.Slides(6)
Set AssumSlide = PPTPrez.Slides(4)
Set RiskSlide = PPTPrez.Slides(5)
'If there is a table in powerpoint slide, delete the table
For PicCount1 = AssumSlide.Shapes.Count To 1 Step -1
If AssumSlide.Shapes(PicCount1).Type = msoPicture Then
AssumSlide.Shapes(PicCount1).Delete
End If
Next
For PicCount = FinSlide.Shapes.Count To 1 Step -1
If FinSlide.Shapes(PicCount).Type = msoPicture Then
FinSlide.Shapes(PicCount).Delete
End If
Next
For PicCount2 = RiskSlide.Shapes.Count To 1 Step -1
If RiskSlide.Shapes(PicCount2).Type = msoPicture Then
RiskSlide.Shapes(PicCount2).Delete
Debug.Print
End If
Next
'Paste the site report table into the site report
Financials.Copy
FinSlide.Shapes.PasteSpecial ppPasteShape
Set FinTable = FinSlide.Shapes(FinSlide.Shapes.Count)
Assumptions.Copy
AssumSlide.Shapes.PasteSpecial ppPasteShape
Set AssumTable = AssumSlide.Shapes(AssumSlide.Shapes.Count)
Risks.Copy
RiskSlide.Shapes.PasteSpecial ppPasteShape
Set RiskTable = RiskSlide.Shapes(RiskSlide.Shapes.Count)
'Set position of site report table in powerpoint
FinTable.Left = 36
FinTable.Top = 175
FinTable.Width = 614
AssumTable.Left = 36
AssumTable.Top = 80.8
RiskTable.Left = 36
RiskTable.Top = 80.8
RiskTable.Width = 641.5
'Set filename as string
fileNameString = Directory & fileN & ".pptx"
'Save file as filename
PPTPrez.SaveAs fileNameString
'Close powerpoint presentation
PPTPrez.Close
'Repeat for every site (column) - increment i
Next i
'quit powerpoint
objPPT.Quit
Application.ScreenUpdating = True
MsgBox ("Update complete, click ok to exit powerpoint")
End Sub
Disabling Windows clipboard history solves this issue.
I've Searched Forums here and I can't seem to get this code to work.
I am Trying to Open a Workbook in Excel, and then populate a few of the Cells(Named Ranges). I can successfully open the workbook(the workbook has a bit of VBA that runs when it opens as well, formatting stuff only) but when I get down to the inputting information I get a 'Run-Time Error "438" Object Doesn't support this property or method.'
From the Previous answers on other similar questions I have done everything the way it was suggested however, I can't seem to get it to work.
Option Compare Database
Option Explicit
Public Sub MaterialInput()
Dim xlapp As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim RsClient As Recordset
Dim RsJobsite As Recordset
Dim db As Database
Dim ClientSTR As String
Dim JobsiteSTR As String
Dim customer As Variant
Set db = CurrentDb
JobsiteSTR = "SELECT T1Jobsites.JobsiteNickName FROM T1Jobsites WHERE T1Jobsites.JobsiteID = 1" ' & Form_LEM.TxtJobsiteID
Set RsJobsite = db.OpenRecordset(JobsiteSTR, dbOpenSnapshot, dbSeeChanges)
ClientSTR = "SELECT T1Companies.CompanyName " & _
"FROM T1Companies INNER JOIN T1Jobsites ON T1Companies.CompanyID = T1Jobsites.CompanyId " & _
"WHERE (((T1Jobsites.JobsiteID)=1))"
'ClientSTR = "SELECT T1Companies.CompanyName FROM T1Companies INNER JOIN T1Jobsites ON T1Companies.CompanyID = T1Jobsites.CompanyID" & _
" WHERE T1JobsitesID = 1" '& Form_LEM.TxtJobsiteID
Set RsClient = db.OpenRecordset(ClientSTR, dbOpenSnapshot, dbSeeChanges)
Set xlapp = CreateObject("excel.application")
Set wb = xlapp.Workbooks.Open("C:\Users\coc33713\Desktop\VISION - EXCEL FILES\VISIONCOUNT.xlsm")
Set ws = xlapp.Worksheets("CountSheet")
xlapp.Visible = True
'Tried this second after reading another forum
'the comments Recordset will be the actual values used, but I can't get the String "TEST" to work
wb.ws.Range("Client").Value = "TEST" 'RsClient!CompanyName
'Tried this way first
xlapp.ws.Range("'SiteName'").Value = "Test" 'RsJobsite!JobsiteNickName"
xlapp.ws.Range(Date).Value = "Test" 'Form_LEM.TxtDate
xlapp.ws.Range(ProjectName).Value = "Test" 'Form_LEM.TxtPlant
xlapp.ws.Range(ScaffoldID).Value = "Test" 'Form_LEM.cboScaffnum.Value
xlapp.ws.Range(ScaffoldNumber).Value = "Test" 'Form_LEM.cboScaffnum.Column(1)
Set xlapp = Nothing
Set wb = Nothing
Set ws = Nothing
Set RsClient = Nothing
Set RsJobsite = Nothing
Set db = Nothing
End Sub
As a Sidenote this is not a form it is just spreadsheet
Thank you everyone!
Use
ws.Range("Client").Value = "Test"
Or
Dim sName as String
sName = "Client"
ws.Range(sName).Value = "Test"
Reason being is that you have the ws object set already, so there is no need to assign parentage to it again. In fact, trying to do so will break syntax rules.
FWIW (not your issue - that is solved by Scott's answer): Note that
Set ws = xlapp.Worksheets("CountSheet")
should be
Set ws = wb.Worksheets("CountSheet").
Using xlapp.Worksheets("CountSheet")
is effectively xlApp.ActiveWorkbook.Worksheets("CountSheet") which might be (and probably is) xlApp.Workbooks("VISION - EXCEL FILES\VISIONCOUNT.xlsm").Worksheets("CountSheet") but it is better to do it correctly rather than leave it to chance.
Thank you guys!
This should do what you want.
Sub DAOFromExcelToAccess()
' exports data from the active worksheet to a table in an Access database
' this procedure must be edited before use
Dim db As Database, rs As Recordset, r As Long
Set db = OpenDatabase("C:\FolderName\DataBaseName.mdb")
' open the database
Set rs = db.OpenRecordset("TableName", dbOpenTable)
' get all records in a table
r = 3 ' the start row in the worksheet
Do While Len(Range("A" & r).Formula) > 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("FieldName1") = Range("NamedRange1").Value
.Fields("FieldName2") = Range("NamedRange2").Value
.Fields("FieldNameN") = Range("NamedRangeN").Value
' add more fields if necessary...
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Right now i am working on a new project where i have to automatize a dashboard.
This dashboard is getting information from avaya scripts.
I searched for the last 2 weeks a script in VBA that actually gets info from avaya reports and imports them to excel file in a certain sheet.
Well, my problem is that i have to export 1 report with 6 different timezones.
For example:
Historical\Designer\Multi Date Multi Split Skill interval - Europe/Brussels timezone
Historical\Designer\Multi Date Multi Split Skill interval - US/Eastern
etc.
Below is my VBA code that works with my cms but it does not take in account that my timezone is set as Europe/Brussels and it exports in default timezone.
Please, help me out so i can ease my work with few hours a week :)
Thank you guys
Sub EMEA()
Dim cvsApp As Object
Dim cvsConn As Object
Dim cvsSrv As Object
Dim Rep As Object
Dim Info As Object, Log As Object, b As Object
Dim CMSRunning As String
Dim objWMIcimv2 As Object
Dim objProcess As Object
Dim objList As Object
CMSRunning = "acsSRV.exe"
Set objWMIcimv2 = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2") 'Connect to CIMV2 Namespace
Set objList = objWMIcimv2.ExecQuery _
("select * from win32_process where name='" & CMSRunning & "'") 'determine if CMS is running
If objList.Count = 0 Then 'If 0 then process isn't running
End If
Set cvsApp = CreateObject("ACSUP.cvsApplication")
Set cvsConn = CreateObject("ACSCN.cvsConnection")
Set cvsSrv = CreateObject("ACSUPSRV.cvsServer")
Set Rep = CreateObject("ACSREP.cvsReport")
Application.ScreenUpdating = 0
Set cvsSrv = cvsApp.Servers(1)
Application.ScreenUpdating = 1
AgGrp = InputBox("Enter Agent Group Name", "Agent Group", "952;953;271;270;221;222;223;224;231;233;232;234;235;246;241;243;242;247;249;245;244;248;255;258;256;259;257;261;262;260") 'change as needed for variables to enter into report
RpDate = InputBox("Enter Date", "Date", "-1") 'change as needed for variables to enter into report
'Start code from CMS Export script
On Error Resume Next
cvsSrv.Reports.ACD = 1
Set Info = cvsSrv.Reports.Reports("Historical\Designer\Multi Date Multi Split Skill interval")
b = cvsSrv.Reports.CreateReport(Info, Rep)
If b Then
Rep.Window.Top = 1830
Rep.Window.Left = 975
Rep.Window.Width = 17610
Rep.Window.Height = 11910
Rep.SetProperty "Splits/Skills", AgGrp 'change as needed for report variables
Rep.SetProperty "Dates", RpDate 'change as needed for report variables
Rep.SetProperty "Times", "00:00-23:30"
Rep.TimeZone = "Europe/Brussels"
b = Rep.ExportData("", 9, 0, True, True, True)
Rep.Quit
If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
Set Rep = Nothing
End If
Set Info = Nothing
' End code from CMS Export Script
cvsConn.logout
cvsConn.Disconnect
cvsSrv.Connected = False
Set Log = Nothing
Set Rep = Nothing
Set cvsSrv = Nothing
Set cvsConn = Nothing
Set cvsApp = Nothing
Set Info = Nothing
Range("A1").Select
ActiveSheet.Paste
End Sub
I use the below script in querysave event of a form. The logic is when I save the form the sequence should get displayed in the view in two columns. like "115-" in one column and the sequence "00001", "00002", ... in the second column. The first two documents gets saved without any issue. When I save try to save 3rd and more documents, its displaying "00002" only every time after that. I am not able to identify what is the mistake. Can somebody help please.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim SESS As New NotesSession
Dim w As New NotesUIWorkspace
Dim uidoc As NotesUIdocument
Dim Doc As NotesDocument
Dim RefView As NotesView
Dim DB As NotesDatabase
Dim RefDoc As NotesDocument
Set DB = SESS.CurrentDatabase
Set uidoc = w.CurrentDocument
Set Doc = uidoc.Document
Set RefView = DB.GetView("System\AutoNo")
Dim approvedcnt As Integer
approvedcnt = Cint(source.fieldgettext("appcnt"))
If uidoc.EditMode = True Then
Financial_Year = Clng(Right$(Cstr(Year(Now)),3)) + 104
If Month(Now) >= 4 Then Financial_Year = Financial_Year + 1
DocKey = Cstr(Financial_Year)& "-"
New_No = 0
Set RefDoc = RefView.GetDocumentByKey(DocKey , True)
If Not(RefDoc Is Nothing) Then New_No = Clng(Right$(RefDoc.SETTLEMENT_NO(0),5))
New_No = New_No + 1
autono = DocKey & "-" & Right$("00000" & Cstr(New_No) ,5)
Application ="ST"
Latest_No = Application + autono
Doc.SETTLEMENT_NO = Latest_No
Doc.FinFlag="Finish"
Call SESS.SetEnvironmentVar("ENV_ST_NO",Right$("00000" & Cstr(DefNo&) ,5))
'Call uidoc.FieldSetText("SETTLEMENT_NO",Latest_No)
Call uidoc.Refresh
Else
Exit Sub
End If
get_ex_rate
get_cv_local
Call uidoc.FieldSetText("Flag1", "A")
If approvedcnt = 12 And uidoc.FieldGetText("STATUS") = "APPROVE" Then
Call uidoc.fieldsettext("Flag2", "B")
End If
Dim answer2 As Integer
answer2% = Msgbox("Do you want to save this document?", 1, "Save")
If answer2 = 1 Then
Print "Saving"
End If
If answer2 = 2 Then
continue=False
Exit Sub
End If
uidoc.Refresh
uidoc.close
End Sub
I imagine your call to GetDocumentByKey is getting the wrong document or not the next one in sequence. Make sure the view is sorted properly and perhaps call the refresh method on the view before calling GetDocumentByKey.