Open Template as New Document

BuffaloGuy

New Member
Joined
Dec 5, 2017
Messages
28
I wrote some code a while back that has done exactly what I needed it to. I have a word document with filler words like Client_Address that when a button is clicked in excel, the word document is opened, a specific cell is coped in Excel and then pasted over the filler word. I have a few dozen of these cases in each word document.

What I want to do though, is instead of opening the existing word document, I want to open the template as Document1 or Blank1, something where I don't accidently save over the word template. Is that possible? I will attached the code as it already exists.
Code:
Private Sub Desktop_Builder_Click()

    Template = "C:\Users\John\Desktop\FORMS\Work Template.docx"
    Set wrdApp = CreateObject("Word.Application")
    Set wrdDoc = wrdApp.Documents.Open(Template, ReadOnly:=True)
    Dim Effective_Date As Variant
    Dim Date_Inspection As Variant
    Dim Date_Written As Variant
    
        wrdApp.Visible = True
    
        wrdApp.Selection.Find.ClearFormatting
        wrdApp.Selection.Find.Replacement.ClearFormatting
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi BuffaloGuy,

I would suggest to not use names for variables which are identical to Parameters used by the application.

Maybe try

VBA Code:
'...
    strTemplate = "C:\Users\John\Desktop\FORMS\Work Template.docx"
    Set wrdApp = CreateObject("Word.Application")
    Set wrdDoc = wrdApp.Documents.Add(Template:=strTemplate)
'...

Ciao,
Holger
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top