dotX | Simple & Beautiful Jekyll theme | Theme library
kandi X-RAY | dotX Summary
kandi X-RAY | dotX Summary
Simple & Beautiful Jekyll theme
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dotX
dotX Key Features
dotX Examples and Code Snippets
Community Discussions
Trending Discussions on dotX
QUESTION
I am trying to insert a table of contents into a Word document using one of the built-in building blocks that define a table of contents. When I record a macro and insert a table of contents the macro recorder gives this line of code:
...ANSWER
Answered 2021-Feb-17 at 03:54The macro recorder is just a starting point. The sample you posted is dependent on a very specific path to the building block template, one that includes your user name and the language you are using (1033 is U.S. English) and the version of Word (16 for Word 2016 and 2019). In addition, the building blocks template location does not have a VBA shortcut to reach it.
What will work more reliably is to insert the table to your macro template or a document based based on that template. Select the table, then choose Insert>Quick Parts>AutoText>Save Selection to AutoText Gallery. You can set the name to whatever you prefer. Set the Gallery to Table of Contents. OK out, then delete the table sample.
Now you can use simpler, more reliable code like this:
QUESTION
So I have been trying to build a simple text editor with tkinter but unfortunately when I use the open() function in Python to open a specific file, an error shows up, saying 'TypeError: 'PhotoImage' object is not callable' on line 83. How is this even related to PhotoImage? Could it be possible that this is related to Image.open() ? Here's the code:
...ANSWER
Answered 2021-Jun-13 at 10:22The problem is you assigned the built in function open
as a variable to PhotoImage
. Now, when you call open
, it fetches the value of the open
variable because it's assigned a value. This will cause the error. That is why you should never use built-in functions as a variable. You can use open_img
or anything that is not a keyword, a built-in function, a function you have defined.
open = Photos(nm + '\open.png', 10, 10)
, this is a mistake
open_img = Photos(nm + '\open.png', 10, 10)
This would work .
Then updated the menu to
fileMenu.add_command(label='Open...', command=openfiles, image=open_img, compound='left')
QUESTION
Our company Logo has been changed. and we have over 5000 templates (.doc, .docx, .dotx, .xlsx, etc) Some of the documents are pw protected, others do not.
A ex-colleague before me created these (the person is not active in the company anymore)
So, I've have "created" a VBA code that semi works. This section is the same for all 3 macros. (only the Call changes)
...ANSWER
Answered 2021-Mar-30 at 06:58The main problem you have it that Word throws a runtime error if you try to unprotect a document that has no protection. Additionally, I would suggest you remove the On Error GoTo ErrHandler
-statement (as it's better to let the VBA runtime to show you the exact statement where an error occurred).
Do a simple change in your unprotect routine: Check first if the doc has a protection. I would suggest that you pass the doc as parameter so you don't rely on ActiveDocument (you need to change the call to Call RemovePwd(doc)
(or simply RemovePwd doc
which means exactly the same)
QUESTION
I have created simple open XML document (.dotx) using MS Word. The file contains simple text and one table. I am trying to replace few custom placeholders in the text with the new text, however the below snippet cannot find any Paragraph
nor Table
in the document. I have tried to create several new .dotx files and also tried different variations of the document type i.e. .dotx
and (Strict Open XML) .docx
using MS Word but the issue still remains.
ANSWER
Answered 2020-Dec-06 at 21:35When you create your document with Editor like MS Word it could add some containers, which wrap your paragraph, I'd suggest you check xml which generated. To do that, you can simply rename .docx
to .zip
and open that archive.
Inside you will found files like that
You will need to open word/document.xml
with any text editor and see, if there and it is direct child of
. If it is not direct, use
descendants
method.
QUESTION
I have made my own Audio Player with JavaScript using the p5.js library. The script loops through all elements of the webpage with onload()
and adds a canvas
(The thing that displays the graphics) object to all html elements of class audioPlayer
. With Firefox it all works fine and it can play an audio file from a specified file path. When i load my website inside of Chrome or Edge, I get the following error message in the console:
ANSWER
Answered 2020-Dec-04 at 08:40The security policy of Firefox is different from chrome and edge. It may be because you open the html file directly on local machine. This will cause Chrome and Edge to be unable to directly access local resources. If you want to run in chrome and edge, please create a web server to run this file.
Be similar to this question.
And you can make chrome have permission to access the file. link
QUESTION
I want to use this Word template to open a new Document
However my code opens the file in "Edit Mode"
...ANSWER
Answered 2020-Nov-06 at 04:31You will want to use the .Add
method instead of .Open
and specify the Template
argument.
QUESTION
Sorry in advance, as I have only been working with C# for about a month with limited history in VB years ago. It's a Mail merge kind of loop that I am trying to create for work to make their life easier. I have the dates figured out. I have a NumUpDown control setting the int myInt
, and a formCount
int starting at 0.
The code worked fine when I used if(formCount==0),
when I switched it to
ANSWER
Answered 2020-Sep-30 at 06:17I haven’t run your code, but as far as I can see, this code would probably fail even without the formcount loop in the situation where you have more than one MERGEFIELD field because you close doc
As soon as you have processed such a field, and yet the foreach loop is processing each Field in doc.Fields.
Even if that foreach loop terminates gracefully, in the next iteration of the formCount loop you are using doc.Activate()
, but doc
has closed so that will fail.
So I suggest that the main thing to do is consider which documents need to be open at which point for the process to work.
Some observations (not necessarily to do with your primary question)
- where is myInt set?
- is having a formCount++ loop and using formCount++ within the loop for every MERGEFIELD in
doc
Really your intention? - you might be better off testing field.Type() when filtering MAILMERGE fields rather than matching the text, at least if such fields can be set up by end users
- when you process collections in Word and you are either adding or deleting members of the collection, you sometimes have to consider using a loop that starts with last member of the collection and works back towards the beginning. Not sure you need to do that in this case but since you may be “deleting” when you do your field.Select then Typetext, please bear that in mind
- It may seem like a complication when you are mainly trying to sketch out the logic of your loops, but I generally find it very helpful to start using try...catch...finally blocks sooner rather than later during development.
QUESTION
I have the below code which runs through as expected for the word creation when I add in the section for save to pdf it runs and saves the first time through. The second loop it builds the word file and saves the file but fails to complete the pdf creation a second time round. I get the following error after the second word file has finished in the loop.
Run time error '462' The remote server machine does not exist or is not available
Quite new to VBA so be gentle with my code!!
Thanks in advance,
David
...ANSWER
Answered 2020-Sep-17 at 15:54As @BigBen pointed out you have some commands inside your loop that should be outside it. I have rewritten your code to show you how you can some additional improvements that will help optimize your code.
VBA code runs more quickly if you avoid selecting things. This applies equally to Excel and Word. Both applications have Range
objects that can be used in place of Selection
.
You also have an undeclared variable in your code, Row
, so you should add that to your variable declarations, (preferably using a different name though as Row
is an object in Excel and confusion can occur when variables have the same name). You can avoid these issues by adding Option Explicit at the top of the code module. This will prevent your code from compiling when you have undeclared variables. To add this automatically to new modules open the VBE and go to Tools | Options. In the Options dialog ensure that Require Variable Declaration is checked.
On the whole though it's not a bad start for someone new to VBA.
QUESTION
I have a a macro enabled excel file (note that this is running on a Mac using Office for Mac) which has several saved macros, one of which is to:
- Create a new .docx document file from a saved .dotx template file.
- Populate bookmarks in the new .docx file with data in the spreadsheet.
- Protect the new document to only allow form fields to be edited by the final user.
- Save the new document to a specific folder.
The code I current currently works except for point 3, I have used Document.Protect method to apply the required protection but seems to have no effect/doesn't work. There is also no error message shown. See current code below:
...ANSWER
Answered 2020-Sep-08 at 16:15It looks as though you are using late binding which means that you cannot use constants and enums from the Word object library, e.g. wdAllowOnlyFormFields
. So your code should be:
QUESTION
I have an Access database with a form that displays information on a record in the database. I've added a button that opens up a new Word document (using a template I've created) and then taking the appropriate fields from the form and adding them to the Word document in the appropriate places (marked with bookmarks). It works exactly as intended the first time in an instance of Access, but it will not work again until I close the database in its entirety and start over again. Any suggestions on why it's only working the first time?
...ANSWER
Answered 2020-Aug-05 at 22:01With Word.ActiveDocument.Bookmarks 'note Word/Wrd
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dotX
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page