We have developed some Microsoft Word tools in VBA that allow a user to add sections to a document with options for A3 and A4 page size and portrait and landscape orientation. We use a form to present the user with radio buttons where (the user) can select new section page size and orientation. The VBA code adds a new section then turns off the header and footer ‘same as previous’ setting, sets margins and adds specific autotexts on headers and footers to control layout of the header and footer, i.e depending on the radio button selected. The document we are experiencing issues with – also has odd and even pages. But also fails in a document without odd and even page layout.
We have used this piece of code for many years on Word 2010 without problem but we are now experiencing inconsistent issues on Word 2016 and in the following part of code. i.e. the code randomly does not turn off ‘same as previous’ even though the code is specifically setting ‘Link to Previous’ to false. Below is a part of the code we used without issues on Word 2010 and fail now:
With NewSection
.Headers(wdHeaderFooterFirstPage).LinkToPrevious = False
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.Headers(wdHeaderFooterEvenPages).LinkToPrevious = False
.Footers(wdHeaderFooterFirstPage).LinkToPrevious = False
.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
.Footers(wdHeaderFooterEvenPages).LinkToPrevious = False
End With
Are there known issues with what we are trying to do above? Why the ‘Link to Previous’ may not be working consistently.
Another issue that can be related to above one, is that on Word 2016 we get below message even when a previous section exists:
Please see the screenshot
It fails randomly on one of the above lines of code, for example:
Please see the screenshot
Is the second issue is related to the first?
Related
There are several instances of this problem, but this one is predominant. This is in relation to updates (our most notable problem child being KB2726958). We have a Leave Spreadsheet that looks like this:
Leave Spreadsheet example
By pressing the grey Leave button, you end up here:
Leave Word doc
All the programming for these is written in VBA (i've never worked with VBA before, I can understand it to a degree).
Now, the issue is that using the ActiveX button in the 'Leave Spreadsheet example' causes the 2 buttons 'Send by Email' and 'Save' to switch functions; Send by email attempts to save and save opens up Outlook and creates the email message.
Both functions have completely retained functionality, just on the wrong buttons.
The thing I find weird is that a hyperlink to the very same file works; the buttons aren't switched and have full functionality. The only hint that I have towards resolution is that when using a hyperlink, it's directly opening the file. When using the ActiveX button, it seems to be creating a new file based off the file it's linking to. For example, the hyperlink directly opens C:\Report.dotm but the ActiveX button opens Document1.doc with a template based on Report.dotm.
I'm considering that maybe the activeX button is opening up Word with an incorrect extension? But i'm not sure how to figure this out (code below shows that the linked file on the activeX control is a .dotm).
What further throws a spanner into the mix is that it only affects some computers... Considering on-site we all use the same type of PC with the same image... :(
My question is, does anyone know why they may be swapping? They're located on the same network drive albeit different directories. They require the same permissions to access. The code for the buttons is as follows:
Excel Button:
Private Sub CommandButton1_Click()
' This button links the excel spreadsheet to the word doc
Dim wrdApp As Object
Dim wrdDoc As Object
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add("\\networkdrive\directories\Request for Leave.dotm")
End Sub
Word buttons 1 and 2:
Private Sub cmdSend_Click()
' This is the code for the button 'Send by Email'
MsgBox "Send the following email to your Team Leader/Line Manager", vbInformation
SendDocumentAsAttachment "", "IPL Request for Leave"
End Sub
Private Sub cmdSave_Click()
' This is the code for 'Save'
modSend.SaveLeaveForm
End Sub
Please Note: The comments above are not in the code in VBA, i've written them in myself in this question to provide clarity.
Troubleshooting that i've done:
Removing all .exd files
Running the MS Hotfix (removes all .exd files in a GUI)
The next step would be to try running all 6 patches related to fixing ActiveX controls with the particular patches we've done to see if that fixes the problem. The reason I haven't done this yet is because of ITIL (Change management) although I may try testing this later today.
What is the outcome i'm after?
Ideally, I want to understand what is causing these buttons to, from what it looks like, swap their functions. I have different scenarios of button swaps, some of which are remedied by removing the .exd files, and some that aren't.
By understanding what is happening, I hope that I can apply the knowledge to the other scenarios (same problem, different coding).
Then, I'll be able to document my findings so that when we perform the next round of patching that is known to break ActiveX controls, my organization will know how to deal with it.
So the patch mentioned below has fixed this issue. There's still some other issues that I need to test this patch against, but I definitely should have started there. Lesson learnt.
From my work email:
I’ve just tried using the patch related to the ActiveX controls breaking, KB2920754. I’ve used it on two PC’s here in the training room; both had different issues:
- The first one had buttons that had switched around (save attempted to email, email attempted to save)
- The second one couldn’t use the buttons at all.
This patch cured both w/o requiring a restart or logging out and back in. I didn’t remove any .exd files, either.
It does state, however:
“Important For this fix to be fully effective, you also have to apply the other patches for Office 2013 that are listed in the "Resolution" section of the following Microsoft Knowledge Base article”
There are 6 in total.
Patches:
1. KB2920754 – (the one I’ve used successfully)
2. KB2956145
3. KB2956163
4. KB2965206
5. KB2956176
6. KB2956155
I'm developing a Word AddIn, and I've run into a bit of a problem.
I need to modify the BuiltIn BuildingBlocks, and to do that, I need an active document.
Since Word 2013 no longer starts with an open document, but instead shows the "New (Latest)" screen, my AddIn creates a new temporary document, modifies the BuildingBlocks as it should, and then discards the temporary document.
The problem is that the act of opening a new document and closing it again, leaves the Word UI at the Home-tab with no active document open, instead of on the "New" screen as it normally would.
So my question is: How do I make Word switch back to the "New" screen?
Here is the before screen, showing normal Word 2013 behaviour on startup:
Here is the after screen, showing how it ends up now, because I open/close the document at startup:
Sorry about the danish screenshots, but the principle should still be clear.
I'm using VB.Net, but C# code can be used too, since it is easily translated.
There is no way to show the Startup screen again. Instead, you may consider running a new Word instance.
Be aware, the Word object model provides the ScreenUpdating property of the Application class which you may find helpful. Here is what MSDN states:
The ScreenUpdating property controls most display changes on the monitor while a procedure is running. When screen updating is turned off, toolbars remain visible and Word still allows the procedure to display or retrieve information using status bar prompts, input boxes, dialog boxes, and message boxes. You can increase the speed of some procedures by keeping screen updating turned off. You must set the ScreenUpdating property to True when the procedure finishes or when it stops after an error.
You may also create a template file with building blocks, then attach the template on top of the new document
It will solve you problem
I am creating a report using SSRS 2008 consisting of a page with a single tablix, a header, and a footer. As far as I'm concern, the report itself isn't that complex. But when I tried to export it to PDF format for printing, several issues ensue:
When using the expression ="Page " & Globals!PageNumber & " of " & Globals!TotalPages in a textbox in the header, the displayed TotalPage number is not equal to the actual total pages in the report.
The pages after the printed TotalPages in the report does not display the page header and footer anymore. For example the actual total page number of the report is 50 but whats printed in the header is Page x of 42; after page 42, the pages does not display the Header and Footer anymore
The tablix applies pagebreaks at random pages eventhough there is no pagebreak condition to any group in the tablix nor on the tablix itself causing half of the page to be blank and the continuation is on the next page.
Does anyone know any fix or workaround on these issues? I've searched high and low on the internet on how to fix these issues but I always arrive at dead end. Please leave comments that you think can help, it will be greatly appreciated. Thanks!
I've helped solve a similar problem a few weeks ago.
Sometimes, any errors in expressions or custom code has side-effects that cascades into the report layout (sometimes causing pagination anomalies, layout issues, etc.). Just check if your expressions are error free, or if there are any scenarios that can cause some expressions or custom code to have errors (like null references, etc).
Also, check if you are calling custom code in a hidden control. From experience with SSRS 2008, custom code inside a hidden control or table row produces side-effects on total page counts, although I've yet to verify if these side effects still happen on newer versions of SSRS (like SSRS 2008 R2).
I'm currently using Word documents as templates where blanks have to be filled dynamically/programmatically in PwoerBuilder.
This has always worked fine until the company moves on Windows 7.
In short, the Word application is opened and made invisible.
Word.Application.Visible = false
Except that sometimes, and I don't know why, once the template is accessed, Word opens itself just as if I had double-clicked the template byself through the Explorer - but I didn't.
So, it asks whether I want to open it in read-only mode, since the application already has a handle on the file. And even if I click [Cancel] not to open the file, Word opens with no document, then the application crashes.
It reports PowerBuilder System Error 35.
Error Number 35.
Error text = Error calling external object function open at line 24 in function of_fusion of object n_cst_9999.
The external object that the application is trying to call a function against is Word.
oleobject lole_word
lole_word = create oleobject
lole_word = ConnectToNewObject("Word.Application")
lole_word.Documents.Open("templatefile.docx")
It may work for a few documents, and after a few, the problem comes up. This is the first time ever I meet with this issue.
I'll be glad to answer anyone's question who's trying to help.
Will, you may try setting DisplayAlerts and FeatureInstall properties on Word Application object.
That hid most of word alerts for us. (The code is from C# project and may not be exactly what you need)
Word.Application.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
Word.Application.FeatureInstall = 0;
You may also try making a copy of the file before opening it to avoid accessing same .docx from different threads - if that may be the case.
OK it's taken me a while to figure this out and it is extremely annoying...
Excel 2013 Pro Plus Fully patched to July 2014
In my project I have
Application.DisplayFormulaBar = False
which works as expected, it hides the FormulaBar. What is NOT expected is that it Stops the inputting of data into any cell.
I have to do a
Application.DisplayFormulaBar = True
to allow the inputting of data again which is inconsistent with the design of the application.
Does anyone know of anyway to hide the FormulaBar and still allow input into cells?
I'm using my own validation inside the VBA code to ensure right place and value...other cells are locked.
Many thanks in advance,
regards
Seán
I'm a Program Manager on the Excel team, and I wanted to provide some input on a bug we discovered that seems related to what we are seeing. Specifically, in Excel 2013 and later, when the formula bar is disabled, you (1) call DisplayAlerts = false (2) from an ActiveX control, you will get into a state where you can no longer edit cells. You didn't mention conditions #1 and #2, but it seemed related, and it might be the same issue you are seeing.
We are fixing this particular issue in an upcoming update to Office365. If you get into this state, one way to work around it by setting DisplayFormulaBar to true, then back to false.
Press Alt+T+O
Advanced
Editing Options
Give a Tick Mark in Allow Editing Directly in Cells
Source (scroll down)