Accept Formatting Changes in Word Headers, Footers and Main Document - vba

I'm using the following VBA code to accept all formatting changes in a document. Which lines would I need to add in order to accept the changes in the Header and Footer as well?
ActiveDocument.ShowRevisions = True
ActiveDocument.ActiveWindow.View.ShowFormatChanges = True
ActiveDocument.ActiveWindow.View.ShowComments = False
ActiveDocument.ActiveWindow.View.ShowInsertionsAndDeletions = False
ActiveDocument.ActiveWindow.View.ShowInkAnnotations = False
ActiveDocument.AcceptAllRevisionsShown
ActiveDocument.ActiveWindow.View.ShowComments = True
ActiveDocument.ActiveWindow.View.ShowInsertionsAndDeletions = True
ActiveDocument.ActiveWindow.View.ShowFormatChanges = True
ActiveDocument.ActiveWindow.View.ShowInkAnnotations = True

Option 1:
Works for all Headers and Footers and the Main Document.
ActiveDocument.AcceptAllRevisions
Option 2
This will only Accept the revisions in the current viewable seciton of the Document.:
ActiveDocument.Revisions.AcceptAll
What you can then Add before is something like:
'Opening the Header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Just run through the various wdSeek Options to go through the various sections if you want to look at specific revisions.
You can also run a script on each revision using a Do or For Loop with:
ActiveDocument.Revisions.Item(x)

Related

How to escape forward slash in Word VBA Find?

I have documents containing hidden markings like these
<tag>tag content</tag>
The tags themselves use a hidden font, the content does not.
I need to find the tag content but the forward slash seems to cause issues
ActiveWindow.View.ShowHiddenText = True
Find.ClearFormatting
Find.Text = "<tag>*</tag>"
Find.Forward = True
Find.Wrap = False
Find.Format = False
Find.MatchWildcards = True
Find.IgnoreSpace = True
Find.IgnorePunct = True
Find.Font.Hidden = wdUndefined
Find.Execute
When I remove the forward slash of one of the tags (and the search string of course) it works fine.
I´ve tried Find.Text = "<tag>*<\/tag>" to escape it but that does not seem to work.
My MS Office language is set to english but the documents originate from a german version, not sure if that matters?
In Word < and > are used as wildcards for the beginning and ending of a word. That's why you have to escape them as well
\<tag\>d*\<\/tag\>

VBA code when refering a SubReport from a Main Report in Access

I am setting an instruction (VBA) in On Load Event on a report in MS Access.
When I open the report,the code works perfect.
But when i try to embeded the report as a subreport on a main report, the code doesnt work.
I think the problem is that I should be referering the field different(Me.Service1...), since I am trying to call the field now from a main report, but i havent found the right syntaxis.
This is the code i wanna embeed on my main report:
Private Sub Report_Load()
If Me.Service1 = "Scanmachine" Then
Me.Vessel.Visible = True
Me.Label400.Visible = True
Else
Me.Vessel.Visible = False
Me.Label400.Visible = False
End If
End Sub
Any suggestions?
Indeed, you need to change the relative reference of your sub report controls. Over the course of my Access database development work, I have used this Access MVPs resource, even bookmarked the webpage (though it uses forms, the same naming setup applies to reports).
Consider the following, adjusting names accordingly and run this on the main report's OnOpen() event:
Private Sub Report_Load()
If Me![subreportcontrolname].Report!Service1 = "Scanmachine" Then
Me![subreportcontrolname].Report!Vessel.Visible = True
Me![subreportcontrolname].Report!Label400.Visible = True
Else
Me![subreportcontrolname].Report!Vessel.Visible = False
Me![subreportcontrolname].Report!Label400.Visible = False
End If
End Sub

Make image visible or not visible based on multiple checkboxes

The following code turns an image on or off based on whether there are two checkboxes checked. The problem is as I add checkboxes only the last two work correctly. In the example below the image does not turn on and off if chk_Pipe1N and chkIn1 are both checked. However it works perfectly when chk_Pipe2N and chkIn2 are both checked. If I add chk_Pipe3N and chkIn3 it will work for this set, but set 1 and 2 no longer work. Any ideas why?
'NIn
If Me.chk_Pipe1N Or Me.chk_Pipe2N And Me.chkIn1 Or Me.chkIn2 Then
Me.imgNIN.Visible = True
Else
Me.imgNIN.Visible = False
End If
'NOut
If Me.chk_Pipe1N Or Me.chk_Pipe2N And Me.chkOut1 Or Me.chkOut2 Then
Me.imgNOut.Visible = True
Else
Me.imgNOut.Visible = False
End If
Simpler (adding #HansUp's comment):
Me.imgNIN.Visible = (Me.chk_Pipe1N Or Me.chk_Pipe2N) And _
(Me.chkIn1 Or Me.chkIn2)

How to enable/disable buttons in excel at once based on criteria?

I have an excel file with full command buttons, I want to disable some buttons with one click.
I'll appreciate your help.
Thanks
With the details you provided in your question, I would say that what you look for is:
By default, all the buttons are saved with ButtonX.Enabled = False (some of them might default with the Enabled = True property if they are meant to be available to all the users);
When the user inputs username and password in the form, you might want to run a code like this:
If userNameBox.Text = "Ahmad" And passwordBox.Text = "1234" Then
Button1.Enabled = True
Button3.Enabled = True
Button5.Enabled = True
'and so on with the buttons you want to activate
End If
Of course, this should be the code of the event-macro related to the submission of the Username/Password user form, let's say:
Private Sub StartUserFormButton_Click()
'code here
End Sub

Multiple Combobox selection Acess VBA

I am trying to create a VBA code that says, if combobox equals this or this or this then have radio button populate. When i use only one bucket (134) it works fine but when i try ti add multiple sections, i get and err.
My code:
If Me.cmbBucketFilter = "134,135,136" Then
'Working Echo Triggers
Me.fmeReached.Visible = True
Me.fmeRecovered.Visible = True
Me.fmeError.Visible = False
Else
'Working Another Bucket
Me.fmeError.Visible = True
Me.fmeReached.Visible = False
Me.fmeRecovered.Visible = False
End If
You're asking it to run only if cmbBucketFilter equals "134, 135, 136" (which it never can). What you really want is for it to run if it equals any of those values.
Change the first line to this:
If Me.cmbBucketFilter IN ("134", "135", "136") Then