MS Project - reset to custom view via ribbon button - vba

So I want to develop a custom ribbon with a button, which upon clicking would switch to a custom view. This ribbon + button would live in the global template, so upon Project_Open event, it would add the ribbon to MS Project, and it would be usable.
I made the custom ribbon via code, and I have the button working.
My only problem is, that when I click the button, I want the custom view to reset to it's "Original form", meaning that if I add/remove columns, or change anything regarding formatting, I would want those to be gone, whenever I click the button.
I can see that the "ResetView" functionality doesn't work like this, since it will reset the custom view completely to it's core view.
How can I achieve this, other than building up the view programmatically from the button click?

Have two copies of the view but each with a different, but identical, table. When the button is clicked, apply the backup view, delete the master view & table, make a copy of the backup view, and apply it:
Sub RestoreView()
Const ViewName As String = "My Custom View"
Const TableName As String = "My Custom Table"
Const BackupView As String = "z My Custom View"
ViewApply BackupView
Application.OrganizerDeleteItem pjViews, ActiveProject.Name, ViewName
Application.OrganizerDeleteItem pjTables, ActiveProject.Name, TableName
Application.ViewEditSingle Name:=BackupView, Create:=False, NewName:=ViewName, Table:=TableName
ViewApply ViewName
End Sub

Related

Microsoft Access can't open a form from inside another form with doCmd.OpenForm

I'm completely new to MS Access but not to databases. I have a form that is meant to open another form through a button and users are to add records to a target table through said form. The main menu fails to open my secondary form saying "recordset is not updatable". The table that is to receive the records is editable and I can go into it and manually add records so this doesn't seem to be the problem. If I click out of the error through the error handler menu I'm taken to the form that I expected to open, but it is read only-- I can't see it's properties sheet, design view, or even change the view at all. I looked at the VBA code on the main menu and it does use doCmd.OpenForm "myForm", , , , , ,"New"
Any pointers would be really appreciated.
Right click your form and click design view. Add a button, click Cancel and name the button appropriately. Than, right-click the button and click Build Event > Code Builder > OK. Copy/paste the code below into the button click event.
Private Sub Command0_Click()
DoCmd.OpenForm "name_of_your_form"
End Sub
That should be all you need to do. Sometimes I have seen Access do some really weird stuff. If the steps I outlined here don't work, try doing a Compact and Repair to reset everything in your DB, and then add the button.

How do I write a macro that has the functionality as Mark Entry button of the References tab in Word Ribbon bar

I need to create a ribbon bar button which will work as a shortcut for the Mark Entry button of the Index group on the References tab. I searched for ways to do this. But I was unable to find any macro which will do this.
This can be done by adding the ribbon bar button in the xml using the following code.
<button idMso="IndexMarkEntry" label="Index entry" />
But I need to put another image as the button icon image. If I use the idmso, I cant use the icon image I want.
So I need to find another way to add this button. I have to write a vb custom routine to replace Mark Entry, but I don't know what to write.
Can anyone help?
I added the functionality to work as a shortcut for the 'Mark Entry button of the Index group on the References tab' and added the custom image as icon to the ribbon bar button (Index entry) that I have created.
Open the .dotm file in Custom UI editor and add the custom image icon to the customUI.xml.
This should be added in the customUI.xml :
<button id="IndexEntry" size = "normal" label="Index entry" onAction="Ribbon.TPS_IndexEntry" image="Index-entry_16" screentip="Mark Entry (Alt+Shift+X)" supertip="Add the selected text to the index" keytip="IE" />
Open the .dotm and open the developer view of the template.
Insert this under Ribbon :
Public Sub TPS_IndexEntry(ByVal Control As IRibbonControl)
Word.Application.Run "TPS_IndexEntry"
End Sub
Then insert this under Macros :
Public Sub TPS_IndexEntry()
Dialogs(wdDialogMarkIndexEntry).Show
End Sub
This will generate a ribbon bar button which will work as a short cut to the Mark Entry button.

Add global button in CRM

Is there a way to add a new button to ALL PAGES in CRM?
I have tried different ways but in some views, the new button is shown at the end. Im trying to found a way to create a button and place it as first button, to any view, entity and page in CRM. Is this accomplisable?
I'm afraid that out-of-the-box buttons will often take precedence over custom buttons, and the only way to change that would be to hide the out-of-the-box buttons.
I'm assuming you are adding the button via the Application Ribbon, correct? (not every single form and grid)
You can add items to the "Jewel", (the dropdown from "File" in the top left). It's not exactly the same as putting it in the ribbon because you have to make an extra click, but it should show up globally.

Loading new form within a navigation tab in ms Access 2010

I have created the following navigation structure in a Microsoft access 2010 database:
You can see that there are two tabs, and the data for the tabs is populated with information linked to the ClientID, which is stored in an un-editable textbox at the top of the form. When the Communications Forms tab is selected, a list of communications forms that have been completed for the specific ClientID is shown. And there is a button to create a new form. My question is how do I write the macro so that clicking on the Create New Form button will cause a blank new form to be loaded in the space that is currently occupied by the List of Forms?
Below is what I have so far. It sends the user to a new form instead of embedding the new form underneath the Communication Forms tab in the current form. How can I change the below so that the blank new form is loaded under the Communication Forms tab in the current form, so that all the navigation controls remain visible/usable?
EDIT:
To address HK1's assumptions below, I am adding the following description of the steps I took to create the form in the screenshot above:
1.) I created a blank form in design view.
2.) I added a listbox to list client fullname and id, and a textbox to filter the listbox.
3.) I added the clientid and fullname textboxes to the form, and set them to change based on
what the user selects from the listbox
4.) I dragged a navigation control onto the form next to the listbox
5.) I dragged a form called "ListOfForms" onto a new tab in the navigation control to create the tab
6.) I added the CreateNewForm command button to the ListOfForms form while embedded in the main form
Here is the result of HK1's suggested code:
While I appreciate it, it does not do what I need. You can see that it just adds an additional row to the list in ListOfForms. Instead, I need the code to place a blank MyForm in the place of MainForm where ListOfForms is currently located. Thus, under the CommunicationsForms tab, all the user would see would be a blank MyForm object, which is a different form than ListOfForms.
When I click on the place where ListOfForms is located in Layout View, I see that it is called NavigationSubForm in the Property Sheet. Thus, NavigationSubForm would swap in MyForm in place of ListOfForms when the user clicks on the Create New Form command button. But if the user clicks on CommunicationForms tab again, ListOfForms would again be placed in NavigationSubForm.
I tried the following:
Private Sub cmdCreateNewForm_Click()
Forms!MainForm!NavigationSubform = MyForm
End Sub
But it generates a Runtime Error '438': Object doesn't support this property or method.
Next, I tried:
Private Sub cmdCreateNewForm_Click()
Forms!MainForm.NavigationSubform.SourceObject = MyForm
End Sub
This causes the NavigationSubForm to go blank, so that ListOfForms disappears. This seems like I am on the correct track, but what do I need to do to get it to put a blank MyForm in the NavigationSubForm instead of just an empty space?
The form you have labeled as "List of Forms" appears to be what's called a continuous form, and I'm guessing it's inside a subform control located on a another form. I'm also guessing that your Create New Form button is probably located on the header section of your continuous form. I'm also making the assumption that your continuous form/subform is bound to an editable recordset/recordsource but there's no way I can tell this by looking at the screenshot.
With these assumptions in place, the code for your Create New Form button would probably be something like this:
Private Sub cmdCreateNewForm_Click()
Me.AllowAdditions = True
DoCmd.GoToRecord, , acNewRec
End Sub
If any of my assumptions above are incorrect than it's likely this code won't work as expected.
Be aware that New Records in continuous forms (and datasheet forms) always appear at the bottom of the list. I'm not aware of any easy way of making them appear anywhere else.

Vba button to activate sheet

I am trying to write the callback for a button on the backstage view.
I want to select a certain worksheet and show it to the user. I thought aboutsheet("sheetName").activate. This is selecting the sheet sheetName, but Excel stays in backstage view.
My question is how can I actually show the sheet, i.e. make it visible? I need to be able to hide backstage view and go to "document view"...
Regards
Add the attribute isDefinitive="true" to the ribbon backstage button xml. It will close the backstage view after the button is clicked and switch back to the main view with the previous tab selected.