Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jun 05, 2019 10:41 pm

Hello,
I was wondering if there is a way to use 1 template file to create multiple files. For example...

Code: Select all
For i As Integer = 0 To MyList.Count - 1
    Dim document As Document = New Document("Template.docx")
    document.Replace("Old Text", "New Text", False, True)
    document.SaveToFile(i & " - Result.docx")
Next


The problem I have is, it only creates 1 file, instead of creating as many as in the list (let's say 10).

Daica
 
Posts: 2
Joined: Fri Apr 05, 2019 5:14 pm

Thu Jun 06, 2019 10:08 am

Hi,

Thanks for your inquiry.
Based on your code snippet, I can use 1 template file to create multiple files successfully. Thus, please check whether your MyList.Count-1 is bigger than 1. If there is still any question or misunderstanding, please share us more information about your requirement,then we will guide you accordingly.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Tue Jun 11, 2019 9:23 am

Hi,

How is your issue now? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Tue Jun 11, 2019 2:55 pm

nancy.yang wrote:Hi,

How is your issue now? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Nancy
E-iceblue support team


Hello!
The issue seems to be on my part.
I had declared the document outside of the loop, it needs to be on the inside of the loop!
Silly mistake, The SPire.Doc is working 100% and is awesome!

Daica
 
Posts: 2
Joined: Fri Apr 05, 2019 5:14 pm

Wed Jun 12, 2019 6:38 am

Hi,

Thanks for your feedback.
Glad to hear that your issue has been solved and thank you for your approval of our Spire.Doc. If there is anything we can do for you in the future, please do not hesitate to contact us.
Wish you all the best!

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Return to Spire.Doc