Free Microsoft Excel 2013 Quick Reference

VBA: Open up Word and activate a template from within Excel

I’m running a macro in Excel. Included in the macro, I would like for the macro to open up Word, grab a label template, that I have stored (have to navigate there), and then merge the data from the excel file into the Word template. Any suggestions would be appreciated.
Thanks in advance

Post your answer or comment

comments powered by Disqus
Declare wordDot as document, open it as template.
Look at below code.
Btw, are you sure to open as template ??

Dim wordApp As Word.Application
Dim wordDot As Word.Document
Dim sPath As String
Set wordApp = New Word.Application
sPath = ""
On Error Resume Next

With wordApp
.Visible = True
Set wordDot = _
.Documents.Open(FileName:=sPath, _ &
ReadOnly:=False, Format:=wdFormatTemplate)


"Doctorjones_md" wrote:

> Tony -- thanks for the quick reply ...
> I'd already tried the following (Word application opened, but the document
> ( didn't -- any ideas as to why?
> Private Sub cmdManaged_Click()
> 'opens a new Word Template
> Dim wordApp As Word.Application
> Dim wordDot As Word.Template
> Set wordApp = New Word.Application
> On Error Resume Next
> With wordApp
> .Visible = True
> Set wordDot =
> .Documents.Open("NetworkProductsClientsOrders .dot", , False)
> End With
> Unload Me
> End Sub
> "Tony Jollans" wrote in message
> ...
> > The template opens because that's what you have coded ...
> >
> > documents.OPEN(etc.....
> >
> > What you want to do is add a new document based on the template ...
> >
> > documnets.ADD("", ....
> >
> > Clicking on a document (.doc file) or template (.dot file) or any other
> > file type causes the default action for that file type to be invoked. The
> > default for documents is "Open"; the default for templates is "New" (i.e.
> > create a new document based on the template)
> >
> > --
> > Enjoy,
> > Tony
> >
> > "Doctorjones_md" > wrote in message
> > ...
> >>I have the following VBA code with opens a Word Template (.dot extension)
> >>from Excel:
> >>
> >> 1. CommandButton1 code on worksheet --
> >>
> >> Private Sub CommandButton1_Click()
> >> SQLRollup
> >> DeleteBlankRows
> >> RollupToSQLServer1
> >> InsertTrackingSpecificData
> >>
> >> frmClients.Show
> >>
> >> End Sub
> >>
> >> 2. Code on frmClients
> >>
> >> Private Sub cmdProposal_Click()
> >> frmOrders.Show
> >> frmClients.Hide
> >>
> >> End Sub
> >>
> >> 3. Code on frmOrders
> >>
> >> Private Sub cmdManaged_Click()
> >>
> >> 'opens a new Word Template
> >> Dim wordApp As Word.Application
> >> Dim wordDot As Word.Template
> >> Set wordApp = New Word.Application
> >>
> >> On Error Resume Next
> >>
> >> With wordApp
> >> .Visible = True
> >> Set wordDot =
> >> .Documents.Open("NetworkProductsClientsOrders .dot", , False)
> >> End With
> >>
> >>
> >> Unload Me
> >>
> >> End Sub
> >> ==============================================
> >> The problem I'm having is that the code in item#3 opens the template
> >> without forcing a new Document1 -- therefore, the template get
> >> over-written by any modifications made while in use. What's curious is
> >> that when I navigate to the file (outside of Excel) and CLICK
> >> on it, a Document1 is created.
> >>
> >> How can I modify the code to do (from within Excel) what simply openning
> >> the file from Explorer does?
> >>
> >> Thanks in advance for any and all suggestions/recommendations.
> >>
> >>
> >>
> >

Hello all,

This question was at the end of another thread, but I felt it more appropriate to re-title it and put it under a new thread because the original question doesn't really apply anymore.

I have the interesting task of exporting each rows value in Excel to a particular field in Word. I have attached a workbook to show what I mean.

I have text totals on a single worksheet and need a way to do the following...

1. Somehow, with code say


"If column A3 says "Chunky Closed", column C3 should say "FIELD 01"
"If column A4 says "Chunky Dented", column C4 should say "FIELD 02"

etc, etc for all 18 columns, using columns E & F as a reference to the Word Document.

2. Somehow, through code from Excel or code from Word, both, or the next best way, (mail merge maybe?) put the totals from B into the Word document, using column C to index or match it.

Questions I pondered myself while thinking about this

>Can Excel/Excel VBA open up Word, if yes, a particular document?
>Can Excel or Word exchange desired areas of text/totals through code?
>If yes, can Excel tell Word to close and save the document under a new name?

Picture the Word Document like a letter that you "TAB" through. Basically, I have a letter and just inserted 18 text form fields and then locked these form fields with the lock button on the Form toolbar. I suppose I should've put "Text Form Field" in the workbook instead of "Field" but at least now you know.

If something other than text form fields should be there instead so that Excel and Word can speak correctly, no problem. I'd be happy to change them from Text Form Fields to anything...such as a FIELD for example. I'm not sure the best route for that.

Thanks much!

Is it possible to execute a program from within Excel 2000's VBA?

If so, how?

MANY thanks!!

Office 2003

I've got a file thats created in excell which is to be loaded to a mainframe as a text file (tab delimited), but due to how excel sees the data it put speech marks in the file, i've created a macro within a word document to open the text file and remove them.

I've done some googling and I know that you can set an macro in excel to open a word doc and excute a macro from within it or have excel open a word document and manipulate it from within the excel macro.

Anyhow i've got as far as below but i keep getting debug errors on the lines in red. can anyone help

Sub manip()
Dim wdApp As Word.Application
Set wdApp = New Word.Application
wdApp.Visible = True
wdApp.Documents.Open Filename:="P:IBM Calendar.doc"
With wdDoc
ChangeFileOpenDirectory "P:"
Documents.Open Filename:="calpot.txt", ConfirmConversions:=False, AddToRecentFiles:=False, Format:=wdOpenFormatAuto
With Selection.Find
.Text = """"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End With
Set wdApp = Nothing
End Sub

Hi All!

Thank you so much with all your help so far! I am looking to see if its possible to write a macro that launches word and runs a macro within word.

I need to have my excel data sourced into a mail merge BUT I need to be able to dictate which word document to merge the data into.

I want to be able to have a msgbox ask me which word document to open.


Have a msgbox say "Which mail merge would you like?"

If I press "3" it will open up "3.doc"

If I press "5" it will open up "5.Doc"

If I press "8" it will open up "8.Doc"

Please let me know if this is possible. Thanks again!

****I have found a way to do this, BUT am I able to run a Word Macro through the VBA? From a batch file I use the /m but it doesn't seem to be working the same way****

How can I open a word document from within excel with VBA and minimize the

Hi All,

I need a macro to open all word files in a directory, do a particular
function, and close the file.

I have to run this from an excel file. can anyone help?


Every time I open MS Word, I get a window saying "Configuring MS Office Small Business 2007

I just installed 2007 MS Office on my new laptop which has Windows 7 Home Premium. Each time that I open MS Word I get the following message: "Configiuring Microsoft Office Small Business 2007". It takes a minute for the configuring to complerte and then I can proceed to create my word document. The other products (i.e., Publisher and Excel) work fine and do not perform this configuring step.
What can I do to eliminate this configuring step each time for MS Word?

Hi all, I have trying to do this over the last couple of days with no luck! What I want to do is using VBA, and from what I think I have found out also DAO, Is to:

Open my Access Database

Open My Report

Apply the Criteria to the Report Data, Based on a Value in my Excel Sheet

Print the Report,

Close the Report and Database.

I have had a go trying to get this to work, and have produced some following code, but I just get an error saying that the report cannot be found.

I have attached my Database with my Report (RECEIPT) which is the report I want to run and add the criteria

Any help will be great, Thanks.

(I am using Access and Excel 2010)


Application.ScreenUpdating = False

Dim DB As DAO.Database
Dim QD As DAO.QueryDef
Dim RS As DAO.Recordset

Dim i As Integer

Set DB = OpenDatabase("C:EPOSEPOS-DB1.accdb")

With QD
    .Parameters("[ENTER INVNO]") = Range("T2").Value
End With

Set RS = QD.OpenRecordset


Application.ScreenUpdating = True

End Sub

I have a workbook that creates a word report from excel data - and now I want to automate the emailing of the Word report...

...I'm kindof assuming that as I've already created a Word object in the code:

 appWrd = CreateObject("Word.Application") 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
...I'd be best off using that object to send the e-mail rather than just picking up the word file as an attachment from within Excel???

Hi everybody!

I have the majority of my code worked out (with previous help from the wonderful people here!) but am getting stuck with getting a formula into a cell from within VBA.

If the formula were viewed from cell C11 in the worksheet it would appear as:


where A11 = A5+7
and C11 = O5 +1 and C5 should be the same as A11! The formula is designed to cross check the two cells.

This formula is repeated several times throughout the worksheet where O5 and A11 are changed as relevant.

I have tried:

Sheets("CSSM Roster A5").[C11] ="=IF(O5+1A11,"ERROR",A11)"

but it is coming up with a syntax error, obviously to do with the ,"ERROR", but I cannot see how to rectify it!

Any help gratefully received!


In my spreadsheet, I have links to many Word docs. There is often a need to
search through the Word docs for those containing certain words or phrases.
This is easily done from within Word. But can I call that Word function up
from within Excel and use it? More specifically, can I "capture" this
within my spreadsheet, and allow my users to access this search function,
regardless of their individual Word and Excel settings? (Assume macros ON,
Word and Excel 2000 on Win2000.)

Thanks for any and all help.


In my spreadsheet, I have links to many Word docs. There is often a need to
search through the Word docs for those containing certain words or phrases.
This is easily done from within Word. But can I call that Word function up
from within Excel and use it? More specifically, can I "capture" this
within my spreadsheet, and allow my users to access this search function,
regardless of their individual Word and Excel settings? (Assume macros ON,
Word and Excel 2000 on Win2000.)

Thanks for any and all help.


I work on several documents that require both worksheets and written reports
- being able to add a word document as a new tab in Excel would be a neat way
of integrating the two into one file for storing/printing/emailing.

How do I save a record from an Excel template to a database in a single step.
Currently, the process is to click on file save, then when the second window
appears, select create new record, and ok. I would like to save the data as
a new record in the database using a single step.

I am trying to open an executable file from within an Excel macro, something
like "SnagIt32.exe" and then close it later automatically in another macro.

I was wondering if anyone could help me with this query. My VB skills are
poor but I'm sure this can be done. My question is this:

I get sent excel spreadsheets via email that contain information requests.
I am looking to see if its possible to
Use Outlook to scan an email when it arrives for a specific subject i.e
"Information Request". Automatically open this worksheet and run a macro
from within this worksheet. This macro would open a pre-designed log
spreadsheet and copy and paste certain cells from the information request to
the log sheet. This way we can keep a record of each request that comes in.

Any help would be greatfully appreciated.

Thanks in advance


Hi everyone,

How can I assign a value held by a global variable into a cell from within a VBA function? Function needs to make some if-then analysis therefore reaching a global variable from within a cell -even if it is possible, is not what I am after. The Function in VBA should be copying the content of a global variable into a cell if certain conditions are meet.

Is there a way to do so?

Thanks in advance


I have a lot of shortcuts to movies for my 5th grade students which won't work. I can launch direct file names but not shortcuts from within excel I can click on a cell to launch a direct file like this = "C:Program FilesOfficexpOffice10winword.exe" /n "c:mode.doc" but if C:modeSC.doc" is a desktop shortcut then it opens winword but not the document. I get " document name or path is not valid" from within winword. But if I go to drive C and click on the shortcut, it opens winword and the ModeSC.doc which is a 1 KB shortcut. Thanks for helping

Hi Guys,

I need to copy and paste a sheet from one workbook into another automatically.

Basically, I need to create a macro that allows me to specify the directory of the other file, copy a sheet from it and paste it into a sheet in the active workbook?

Not sure how to proceed?


Tried to extract a picture from an Excel worksheet and save it as a *.jpg /
*.gif / *.bmp file - don't know how to do. Anyone knows how to do that? Same
goes for Word.

SharePoint- upgraded from 2003 to 2007 office and close file command from within Office app, not prompting for check-in

We recently upgraded to SharePoint- and Office 2007. Former documents that were office 2003 versions are not prompting for check-in when you click close. Even though the document library requires check-in/out required and publish major minor versions, it just behaves quirky with saving to local drafts folder as well. Therefore, you have to go back into SharePoint to check it in. And then the changes made are not appearing. I can give workarounds and solutions, like check in check out publish major, save as. but hoping for a better fix. 
I had the user check the file locations in the new .ppt, and browse the folders for the my documents > SharePoint draft folder. It appears to be related to the default path location being different than  but how can I simply get everything in synch to make it easy? I reviewed a fix specified online referred to in KB134725. Would a repair fix the problem? Is this something that can be updated or automated by our office implementation team? It's a corp wide upgrade, and I know they just left the defaults. I am a support person and can make recommendations or suggestions.

 When Word is initially installed, this setting is left blank by the Setup program. If this setting is left blank (not modified), Word uses the last option in the hierarchy. This last option is the "Documents" folder (in Word 2007) or the "My Documents" folder (in Word 2003 and in earlier versions of Word).

After you modify the Documents setting, any changes that you make in the default file location will be registered here even if the setting is returned to the original location (the "Documents" folder in Word 2007, and the "My Documents" folder in earlier versions of Word). This setting will take precedence over the original documents folder that was set at installation.

In Word 2003 and in earlier versions of Word, if the Documents field on the File Locations tab is blank, Word displays the "My Documents" folder in the Save As dialog box. In Word 2007, if the Default file location box is blank, Word displays the "Documents" folder in the Save As dialog box.

This folder is created during the setup of Word and Office for Windows. This folder is registered in the Microsoft Windows registry. All Office programs save files in this location.

To change where Office applications store their files, you must edit the Windows registry. To edit the Windows registry, follow these steps.

Hi, I was wondering if there is a way I can open another program (one which has nothing to do with Excel) from within Excel VBA? If possible, I could also do with closing the program once the module has run if this is also possible.



Hello there expert excellers!

I am trying to retrieve a cell value from another excel sheet using the VLOOKUP function.

Basically what I want is for excel to search columns in another excel file and if it finds it I want to retrieve the value next to it. For example, I want it to search 'food' in another excel file and when it finds it I want to retrive value next to it such as 'apple':

please help and many thanks.

No luck finding an answer? You could always try Google.