Macro fails in Word 2013 - vba

I have a Word macro that has been working fine for ages. I have recently upgraded to Word 2013 and the behavior has changed.
It occurs on the following line:
Doc.SaveAs Path + "Manual\" + TitleString + ".htm", wdFormatFilteredHTML
which builds a valid file path and name and saves the current document as an HTML page.
Under Word 2013, the macro opens a file save dialog box with no filename and with the default file extension (.docx) instead of (.htm), as if the filtered HTML mode was no more available.
I have tried with named arguments, and also with the new SaveAs2 method, but saw no change.
How can I solve this ?

I fond this comment on the DataZX.CN forum:"I Had the same problem. I'm running a windows 8/64bits on an ACER laptop. SOLUTION : remove the Add-in "Icloud Acer ...".
I happen to use Acer desktop, and there was indeed this Icloud add-in pre-installed in Word. After disabling it, the macro works !!!!!!!!!!!!!!!

Thanks StackOverflow for pointing me in the right direction as always...
and thanks Yves for spreading the info...
I removed Acer cloud plugin from Word and excel just to be on safe side.
Blame foolish manufacturers like Acer for another bundled piece of crap software that causes more harm than good.
Quoted from MSDN forum post...
http://social.msdn.microsoft.com/Forums/office/en-US/59c0da80-a7e6-4026-855c-f6b9fbf9c386/word-2013-vba-documentsaveas-dialog-appears-even-applicationclassdisplayalerts-?forum=worddev
...From all you tell me, my feeling is that there may be another third-party application (or a virus) mixing in - that the display of SaveAs is not coming from your application.
This is difficult for you to test, since whatever it is is probably loading with Word...

Related

Convert Excel to PDF in SSIS Not Working

I have SSIS code that converts Excel to PDF in a script task similar to this posts code: Code to Convert Excel to PDF using VB.NET. The SSIS job runs all the way to where it exports to excel:
oWorkbook.ExportAsFixedFormat(pFormatType, PDFFileName, pQuality, _
pIncludeDocProperties, _
pIgnorePrintAreas, _
pFrom, pTo, pOpenAfterPublish)
Once it hits this block of code my SSIS job freezes. I have my application.displayalerts set to false thinking that somethiing pops up but that is not the problem. I also have PDF reader installed on my server and that doesn't help either. This code works on my PC but not on the server. I cannot seem to figure out why this is happening. It seems like the code referenced in the link does work also. Any ideas why my code doesn't work on my server?
You can't reliably call desktop applications from a server process that has no desktop.
It's probably missing something like Acrobat or a print queue and is waiting for user input that will never come.
If you need to reliably create PDFs from excel using an automated process, you'll need to look at 3rd party tools or writing something.
I can't locate it right now, but Microsoft has a technote somewhere that mentions this.
So I dug a bit deeper. I was able to run SQL Agent in interactive mode and I could see a pop up stuck in Excel (or at least see a pop up with a title "printer setup", the screen was all wigged out otherwise). I googled that and found this other posting: Excel automation: PDF export causes "Printer setup" popup that describes my problem. He fixed his problem, which worked for me as well, by changing the default printer to the microsoft XPS document printer. Hope this helps someone else.

Microsoft Access - Missing Reference to acrobat.tlb

I am working with a Microsoft Access database that was mostly completed in Access 2010, and now I am opening it on a new computer that has Access 2013.
Upon opening the program, it tells me,
"Microsoft Access database or project contains a missing or broken reference to the file 'acrobat.tlb' version 1.1."
I have done some research, and I know that I need to go into the VB code and go under tools->references. Now under here it lists the working references then says,
"MISSING: Adobe Acrobat 10.0 Type Library"
So now I understand, that I need to give it the reference to that .tlb file. I am good up to here, but whenever I try to browse I can never find this file. I just downloaded Adobe, so I know I have the most recent version.
I saw a couple places in my research that you can just uncheck the box and try compiling again. This however does not work for me. it needs this reference for several things I am doing.
Has anyone ever had this problem or have any guidance for me?
Thank you!
I'm not 100% on this, but loading Adobe by itself may not give you the library you are looking for. You could need the file which is located in the SDK (which happens to be free) adobe site. Try installing this, and see if you can navigate to the tlb.
SQL hound was right. To expand on what he suggested and be more specific for this issue for those with this problem in the future, you need to download the Acrobat DC SDK (not the air one). In InterappCommunicationSupport/Headers you will find acrobat.tlb.
I am using Access 2013 and Acrobat Pro version 11.0.
I have looked for the file "acrobat.tlb" on my drives.
Found it under: "C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat"
In the Visual Basic Code "tools/references", I clicked "Browse" and went to the location I have found, selected the file and clicked OK.
Returning back to "tools/references", the "Adobe Acrobat 10.0 Type Library" is now available and selected.
I have run minimal code to open and show the number of pages of the opened "pdf" document and it returned the proper number of pages.
Just so you know:
I now remember that there was a selection called only "acrobat", it is now gone. Must have been caused by selecting manually the desired file.
Maybe that selection was pointing to the "acrobat.tlb" file.
You can see the full path and name of the file corresponding to the selected library name at the bottom of the reference window.
I had the same problem but I had a Missing reference to "...Adobe 9...Type Library..." I unchecked that and tryed with, "Acrobat Access 3.0 Type Library" futher down. Then it worked.

Word Automation Service breaks links in table of contents

I have written a code which utilizes Word Automation Service in order to convert the .DOCX file to the .PDF. I have noticed that in case the Word document contains a table of contents, its links are removed in the PDF. This is very bad for my business case.
On the other hand, manually opening MS Word and saving the same document as PDF preserves the links in the table of contents. This is the behavior I am looking for, but I want to keep my code independent form having MS Office Word installed on the machine running my code.
Has anyone had the similar issue and was anybody able to resolve it?
In my case, i found out that this is something related to Job Settings property. Try to comment or remove this line of code if you have one:
jobSettings.UpdateFields = true;

How do I get rid of Word VBA project junk?

When I look at Word VBA on my work computer I have what looks like junk projects. On another PC I have only the normal and currently open documents? Is there a way I can clear this?
These are either hidden documents belonging to addins you have installed, or they're documents that have ended up in your Word startup folder.
Under file..options..addins, check in "Active Application Add-ins" that you don't have anything you didn't want or know about.
Under file..options..advanced..general..file locations, note down the folder for "Startup". Look in that in Explorer and make sure those TMP files aren't in there (you may have to turn on hidden files).
Chris

How to Pretty print VBA code?

How do you copy VBA code into a Word document and retain the VBA editor color scheme?
You can use Notepad++ to accomplish this in three ways. Just so you know, Notepad++ is a more advanced version of Notepad, which supports syntax highlighting of different code files "out of the box" - Visual Basic included!
Download & install it, fire it up, and load up your VBA code. You should automatically see it beautifully coloured (if not, because the file extension is something other than .vb, go to Language -> VB or Language -> V -> VB).
If you need to change any of the colours, you can easily do so - just go to Settings -> Styler Configurator. From that menu, you can change the various highlighting and font options, to suit your needs - although the default usually suffices for most.
Then, go to Plugins -> NppExport. From there, you have three options you can consider:
Directly print from Notepad++
Copy all formats to clipboard
Export to RTF
Export to HTML
The first is self explanatory. The second one - "Copy all formats to clipboard" - will copy the entire file with the highlighted syntax to the clipboard. Once you click it, then open Microsoft Word or your other favourite document editor, and just hit paste! You should see the beautifully syntax-highlighted code. If something goes wrong, then you can try one of the other options (export to RTF/HTML), although I've never had a problem with the clipboard method.
There are two programs on cnet downloads, which are free to try. In case you did not try them, here are the links:
VB-VBA Code Formatter & Printer 2.2
VBAcodePrint 6.13.110
Smart Indenter could be what you're looking for? You'd load the result into Notepad++, set language to VB and save as .rtf/.doc (or print to file, can't remember off the top of my head).
For a more modern approach, Sublime Text users can install ExportHTML from Package Control. This has the added benefit of being able to include the line numbers, and changing the code coloration.
HTML files can be opened directly within Word.
Highlight supports a wide range of Operating Systems and 150+ languages including Visual Basic, although I'm not sure about VBA.
I would recommend this one: planetB
It works well with Internet Explorer (didn't work wit Firefox for me, not sure abt Chrome).
Plus it's online, so no need to install anything (the case of Company/University PC's)
Regards
Wheeliam
The following works with Visual Studio Code:
Start VS Code.
New file.
Copy & Paste the VBA code into the VS Code window.
In the lower right-hand corner, click on "Plain Text" and select "Visual Basic" instead. Note that the code is now syntax-highlighted.
Copy & Paste the formatted code into Word.