0
votes

This is probably a pretty trivial question to answer, but I'm very new at VBA, so my knowledge is pretty patchwork.

Basically, what I've done is I've got some VBA code in excel that I want to use to create a new word document from a template and then find/replace some marker text I've placed in it based on what's in the excel workbook. I think I've got the find/replace part down, but I can't seem to get the word document to open properly.

Here's the relevant code:

Set wordApp = New Word.Application
wordApp.Documents.Add Template:=ThisWorkbook.Path & "\Template.dotx"

When I run this code it executes fine, and a new WINWORD.EXE process is spawned, but no new windows open, and as far as I can tell the document isn't actually open or active.

The workbook with the code and the template are saved in the same folder, so the path to root should be the same for both. I also have already added a reference to Word in the VB editor.

Like I said, this is probably pretty simple to fix. If someone can give me some guidance it would be greatly appreciated!

1
I has been a while, but there is likely an object something like window show that you have to set to true in order for the document to appear on screen. Take a look in the VBA reference under Application to see if there is a method like that.AMR

1 Answers

3
votes

Add the line wordApp.Visible = True after you are done with all of your code implemented changes. That way the user cant mess up what your macro is doing

I hope that helps!