473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Error When Create a Blank Word document

28
I create a blank document like this:

Expand|Select|Wrap|Line Numbers
  1. Private Word_App                    As Word.Application
  2. Private Word_Doc                    As Word.Document
  3. Private Word_Rtf_Doc                As Word.Document
  4. Private Word_Table                  As Word.Table
  5. Private Word_Range                  As Word.Range
  6. Private objRow                      As Row
  7. Private objCell                     As Cell
  8. Private sCellText                   As String
  9. Private Range                       As Range
  10. Private strPath                     As String
  11. Private iMarcaPaginas               As Integer
  12. Private iMarcaCartasIndividuais     As Integer
  13. Private strTempLogo                 As String
  14.  
  15. iMarcaPaginas = 0
  16. iMarcaCartasIndividuais = 1
  17. strPath = strCaminho
  18. Set Word_App = New Word.Application
  19. Set Word_Doc = Word_App.Documents.Add(DocumentType:=wdNewBlankDocument)
  20. Set Word_Range = Word_App.ActiveDocument.Range()
  21. Word_App.Options.CheckGrammarAsYouType = False
  22. Word_App.Options.CheckSpellingAsYouType = False
Then I fill the document with 1 image, some text and a table with values. What I really need to do is:
When The document is complete, I need to save it as a .pdf file THEN create a NEW ONE, Blank Document, to fill it again with others data but with the same functions

the method to create a blank document is inside a loop, and it's working FINE. But when it comes to create the blank document of number 407 and it tries to run this line of code, it gives me an error:
Expand|Select|Wrap|Line Numbers
  1. Set Word_Doc = Word_App.Documents.Add(DocumentType:=wdNewBlankDocument)
  2. Word_App.selection.Paste
With this, I create a new blank document(I think so) and I just past what was copied in the first time.

What could it be? Why the error happens only when I try to run this in the 407th time ?
Sep 13 '13 #1
1 1438
Ghaleon
28
I solve the problem just adding

Expand|Select|Wrap|Line Numbers
  1. Word_Doc.Close False
  2. Set Word_Doc = Nothing
Sep 16 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: di | last post by:
I have a Access Database, and I would like to create a word document that (preferable would filter)links to ACCESS table or query. I would like to print the word document on the filtered record...
3
by: Michael Tkachev | last post by:
Hi Everybody! I have a problem. When I get a HTML of my page that I'm rendering. I need to generate a word-document from a html. And than I have to send this word-document to the users through...
3
by: Mantorok | last post by:
Hi I'm getting the following when clicking a link to a word doc: System.Web.HttpException: Path 'OPTIONS' is forbidden. at System.Web.HttpMethodNotAllowedHandler.ProcessRequest(HttpContext...
0
by: jayne | last post by:
I have created the following code the first part works to create a word document with but when I have created the document and existed word, I then click the button again to open up the document to...
3
by: Ken Swinton | last post by:
I am developing a program that gathers inspection visit details and save them in string variables. I need to output this information to a Word template. I have attempted to use Bookmarks, so far...
1
by: Jordan | last post by:
Can someone point me in the direction of a method/solution for generating word documents on the fly? I have been programming my files in rtf, but the filesize gets tooo big when I start using...
4
by: sunil | last post by:
Hi, I have to open a word document from my aspx page.The Page_Load method contains the following code System.IO.TextWriter tx = Response.Output; System.IO.StreamReader sr = new...
0
by: gopikrishnan | last post by:
Hi to all, i am developing a java project which workes in linux. I need to create a Word document through my java program, rep_path = --FIlePath-- fso = new File(rep_path); if (!...
0
by: 5anelli | last post by:
Hi to everyone, I need to create and print (from within a c# application) a MS Word document starting from an Access db. Half of this document must be written and printed in, let's say, January,...
2
by: uamusa | last post by:
I am Dynamically generating a proposal(report) in MS Word. By default the Paragraph Alignment is "Left". For the First 6 Paragraphs I set the Alignment to "Center", and then when attempting to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.