Sign in to follow this  
Followers 0
Floppy

Change the font in Word 2013

17 posts in this topic

Hi everyone,

I'm trying to open an existing Word doc and change the font of every "S" character to "Wingdings 2".

I took a look at the help file and found that this can be done using the function _Word_DocFind. I tried the Example 1 of _Word_DocFind but doesn't seem to work. I'm running Word 2013.

Please can you help me?

Thank you!

Share this post


Link to post
Share on other sites



The example in the help file for _Word_DocFind works fine for me.  Can you provide more information about what is not working?  Also, if you are 2013 make sure your file extension to open is .docx.  Did you create the Test.doc file with the string to find in the example?

JFish


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Yes, please post your script or a reproducer script so we can test here.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The example in the help file for _Word_DocFind works fine for me.  Can you provide more information about what is not working?  Also, if you are 2013 make sure your file extension to open is .docx.  Did you create the Test.doc file with the string to find in the example?

JFish

 

The text dones't become bold. I'm using the first example in the help file.

I din't creare the Test.doc file because it already exists.

Yes, please post your script or a reproducer script so we can test here.

I already said I'm talking about the Example No. 1 in the help file.

Share this post


Link to post
Share on other sites

 

I din't creare the Test.doc file because it already exists.

Are you saying that file is included with the help file?  If so, where?  Maybe it would be good if you attached the Word file you are using.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

I already said I'm talking about the Example No. 1 in the help file.

I know!

But example 1 sets the found text to bold.

You want to modify the font to "Wingdings 2". This means you modified the example script.

That's why I wanted to see the code you run.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Are you saying that file is included with the help file?  If so, where?  Maybe it would be good if you attached the Word file you are using.

 

It's in "@ScriptDir & "ExtrasTest.doc".

I know!

But example 1 sets the found text to bold.

You want to modify the font to "Wingdings 2". This means you modified the example script.

That's why I wanted to see the code you run.

 

I didn't modified the example script yet because I tried it as it is and it doesn't work. First I want to understand why that example doesn't work, then I will modify it to change font.

Edited by Floppy

Share this post


Link to post
Share on other sites

Can't test at the moment but I know that the examples worked fine with Word 2010.

Will give it a try on monday and report the result.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ok, thank you! Please remember I'm using Word 2013.

Share this post


Link to post
Share on other sites

If it works with Word 2010 and doesn't with Word 2013 then we know that something changed between versions.

At least we then know where to continue to search for the bug.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

All examples for _Word_DocFind just work as expected when being run with AutoIt 3.3.12.0 and Word 2010 32 bit on Windows 7 64 bit.

Even worked with AutoIt 3.3.13.19.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I have Office 2013 I can test on, but (as has been asked repeatedly) the OP needs to post the code he is using...


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

He mentioned that he didn't modify the first example taken from the help file for _Word_DocFind.

Could you please run this example and post the result (means: gets the text "test document" marked as bold)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Sorry, took me a couple of days to get back around to this. I have confirmed the example does not work for Office 2013, for 3.3.12.0 or 3.3.13.19, x86 or x64.

I will have a look this weekend to see if there is a simple workaround we can translate from VBA.

Edit: Not sure why, but it seems to be an issue with _Word_DocOpen. In the Example script, the ReadOnly parameter is set to True. This does not pose a problem up through Office 2010, but seems to be a hitch in 2013 (which makes no sense to me).

Once I changed this:

Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)

to this:

Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, False)

...the example worked.

It doesn't make a lot of sense to me, but @OP, can you please try the same and let us know?

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks for the feedback!

As the AutoIt install directory is readonly I had to change the examples to avoid error messages when calling _Word_DocOpen.

AutoIt sets @error = 4 when a file can not be opened read write.

After discussing the issue with some MVPs I changed the Excel UDF in August to not return an error but to set @extended in this case.

Seems I missed to do the same for Word but I think this is needed for Word as well.

What do you think?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I think that is a good plan, keep it consistent.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

 

It doesn't make a lot of sense to me, but @OP, can you please try the same and let us know?

I can confirm it works in Word 2013 x64. I'm running Windows 8.1 x64.

Thank you very much! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0