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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,215,753
Messages
6,126,675
Members
449,327
Latest member
John4520

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