Restoring MS Project Views - ms-project

I'm running a user defined script that changes the view during the course of its computations. When I launch the VBA script, the view is in no particular filter, table or view name. I want to restore the view just as it was before the user launched the script including which task has the focus. It seems like naming the view as the first step when the script launches and saving the task which has focus then activating the view and focus at the completion of the script is a potential way to do this but I'm not having any success. I would delete the named view at the end of running the script. Any suggestions or point me to previous discussions on this forum that may have answered; my search didn't reveal any.
Rod Gill suggested the following but unless I'm doing something wrong it doesn't appear to work.
Dim OrgnlID As Long
Dim OrgnlView As String
Dim OrgnlTable As String
Dim OrgnlFilter As String
OrgnlView = ActiveProject.CurrentView
OrgnlTable = ActiveProject.CurrentTable
OrgnlFilter = ActiveProject.CurrentFilter
OrgnlID = ActiveCell.Issue
' place your code here that does the view manipulations
' followed by the lines below to restore the view before manipulations
ViewApply OrgnlView
TableApply OrgnlTable
FilterApply OrgnlFilter
EditGoTo ID:=OrgnlID

Related

Access 2013 unable to add new line to form and runtime error 2105 when trying to a new record

I am migrating several adp files to accdb so that it can work under access 2013 but one problem is driving me nuts:
I have a form on which I cannot see an empty line to add new data.
the form property allowaddition is on
the recordsource of the form is an sql View to which I can add a new line directly from access (so it is not readonly)
I am forcing the AllowAddition on the code when initializing security with me.allowadditions = true (this used to be enough to make it work in the old adp)
I have a button to add a new line to the form that runs on_click and gives me a runtime error on this line of code Docmd.gotorecord , , AcNewRec
The runtime error is "2105 : you can't go to the specified record".
This tells me that there is something that is still read only.
the SQL View has an index as well as all the table used in it.
I tried to replace the view in the recordset of the form by a table and still not working.
Am I missing something? What else can I do to be able to add a new record to my form (or view)?
Thank you
Try setting focus to one of the textbox controls in your form before calling the new record, something along the lines of
me.txtControl.SetFocus
The reason is, SQL Server backend allocates new records differently than Access backend, and Access does a bit of magic for you in the interface, so I've found sometimes explicitly setting focus to a text control will fix this issue.
Depending on how things are structured with your Access app, if that suggestion doesn't work, then you might need to go the extra step of programatically creating the new record (blank fields except for primary key) in SQL Server first and then refresh the Access form and then setfocus to the newly created record (e.g. either the last or first record depending on your recordsource sort order)

Trigger excel solver from vb.net web app

Using vb.net, visual studio 2013 and excel 2010.
I have a web page and when a button is clicked values are passed from the page to excel ( a presaved formatted copy). I then want to run the solver add in (which I have also preconfigured). I have been searching for a while now and cannot find a way of doing this.
The below is the code I use to open the excel application
Dim xlApp As Excel.Application
Dim xlWorkbook As Excel.Workbook
Dim xlWorksheet As Excel.Worksheet
xlApp = New Excel.Application
xlApp.Visible = True
xlApp.DisplayAlerts = False
xlWorkbook = xlApp.Workbooks.Open("c:\temp\RTO.xlsx")
xlWorksheet = xlWorkbook.Sheets("Optimiser")
Another curious problem that may be related is when I open excel from the web page the solver addin is enabled in excels options but does not appear in the data ribbon tab. If I disable and enable it in the options it comes back.
UPDATE
I tried the following code
xlApp.Run("C:\Program Files\Microsoft Office\Office15\Library\SOLVER\solver.xlam!Auto_Open")
But it errors with the following
Additional information: Cannot run the macro 'C:\Program
Files\Microsoft Office\Office15\Library\SOLVER\solver.xlam!Auto_Open'.
The macro may not be available in this workbook or all macros may be
disabled.
Ok, so
1) a website that populates excel with data and then streams the excel to the client.
2) the client then fill out or manipulates stuff in the excel.
3) Then clicks a button to solve and perhaps submit the excel...(where you are stuck)
Step 3 could be accomplished with a small 'one click application ' aka 'clickonce', whereas the application is online and served from your site. You could take one cell of your excel and have it open IE and point to the installer, and even pass a parameters (be sure to allow params to pass in the app) as to where the excel was located. Then the app could interop with the excel and do its stuff, perhaps even deliver data back to the server.
After further research and thinking about my problem, I came up with the following.
I cannot find any help about triggering solver from within my vb.net code but you can trigger a macro.
First I added the following code which loaded solver.xlam into excel once it had launched.
xlWorkbook.VBProject.References.AddFromFile("C:\Program Files\Microsoft Office\Office15\Library\SOLVER\solver.xlam")
I then created a macro in excel to launch solver. Once done I added the following line of code into my web page. Runsolver is the name of the macro.
xlApp.Run("RunSolver")
Hope this helps someone else down the line

Change SharePoint site name using a Feature

I am running into a problem when creating a SharePoint 2010 Feature. What I am trying to do is:
Check to see if the site name is the same as the site title.
If it isn't, change the name (and therefore the URL) to match the title.
My code is as follows:
Private Sub ChangeSiteNameToMatchTitle()
_web = SPContext.Current.Web
If _web.Name <> _web.Title Then
_web.Name = _web.Title
_web.Update()
End If
_web.Dispose()
End Sub
This successfully changes the name so that it's identical to the site title, but it causes the Feature to crash at the end of it's activation cycle due to the fact that the site name (and therefore the URL) has changed.
The Feature appears to be trying to reload the ManageFeature.aspx page on the site that activated it, but since the URL has changed it cannot find the page any more.
Does anyone know of a workaround for this, or even if it's possible?
Many thanks!
I would make the Feature hidden and activate it outside of the UI using PowerShell.
Also, per best practice rule SPDisposeCheckID_220, you should not dispose SPContext.Current.Web:
SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPSite and SPWeb objects returned by SPContext.Site, SPContext.Current.Site, SPContext.Web, and SPContext.Current.Web.

ReportViewer is not displaying data .

I want to use Report Viewer in my project.
i have
1. CustomerDetails - Stored Procedure
2. CustomerDataset.xsd - in which i dragged n dropped the stored procedure.
3. CustomerReport.rdlc - in which i have crated a table which and data set is
CustomerDetails
4. CustomerReportViewer.aspx - in which the CustomerReoprt.rdlc is being binded.
now, i want to pass 2 values "chkeckInDate" and "checkOutDate" from 2 text box which are to be filled by use from "main.aspx" also i 'm calling my stored procedure from this file .
the report viewer is getting displayed but, the contents are not getting displayed (i have executed my stored procedure and it is running perfectly.)
How can i fix it? please help.
I didn't clearly understand where is the mistake, but I think you have the code under page_load event. Copy the code into button_click.
This is what I've used..
You must inport this:
Imports Microsoft.Reporting.WinForms
You should pass the textbox value as parameter.
Dim yr As New ReportParameter("param1", TextBox1.Text)
Try
Me.your_TableAdapter.Fill(Me.DataSet_name.table_name)
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {yr})
Me.ReportViewer1.RefreshReport()
Catch ex As Exception
MsgBox("try again")
End Try
copy these two lines from page_load event into button_click.
Me.your_TableAdapter.Fill(Me.DataSet_name.table_name)
Me.ReportViewer1.RefreshReport()
Further, watch this

How can you extend the default behavior of Tridion.Cme.Commands.Open.prototype._execute()?

I have written a GUI extension which adds an additional tab to many of the Item views in the SDL Tridion CME (e.g. Component, Page and Schema etc.). I have also written some JavaScript which loads that tab directly if when the view is loaded with a tab name is specified in the URL.
The result is that if a page is loaded with the tab name added as follows:
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64&tab=InfoTab
Rather than the default of
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64
The Info Tab will be loaded on top, instead of the General Tab. This is performed with the following code snippet and works very well:
$evt.addEventHandler($display, "start", onDisplayStarted);
// This callback is called when any view has finished loading
function onDisplayStarted() {
$evt.removeEventHandler($display, "start", onDisplayStarted);
var tabname = $url.getHashParam("tab");
if (tabname != '') {
var tabControl = $controls.getControl($("#MasterTabControl"), "Tridion.Controls.TabControl");
tabControl.selectItem(tabname);
}
}
Now I would like to make a context menu item to open items and link to the tabs using my new functionality. My first thought was to construct the Item URL myself and simply open a new window in my execute method. So I looked at the default functionality in the standard Open.prototype_execute() functionality of the GUI. This is stored in the navigation.js file of the CME, and is performed by the Tridion.Cme.Commands.Open.prototype._execute method. The code is a lot more complicated than I had anticipated as it deals with shared items, and permissions etc.
Rather than just copying all of this code to my own function, I was wondering if there is a way to elegantly extend the existing Open.prototype_execute() function and append my “&tab=MyTab” to the $cme.Popups.OPEN_ITEM_OPTIONS.URL constant for my own functions.
Any advice would be greatly appreciated.
At the end the Open command uses $config.getEditorUrl(item_type) to get the url for the item view (item_type - $const.ItemType.COMPONENT, etc). There are no extension points for this part of the functionality, but you could always try to overwrite it on your own risk.

Resources