+ Reply to Thread
Results 1 to 5 of 5

Save as and creating loop for more word documents

  1. #1
    Registered User
    Join Date
    01-21-2014
    Location
    Newhouse
    MS-Off Ver
    Excel 2010
    Posts
    5

    Save as and creating loop for more word documents

    I have 60 rows with 7 different tables, I am using office 2010.
    Now I want to export the value of cells to the word document and paste them on a specific location and repeat it for 60 times with every time a different value.
    Also I would like to save it with a cell value and that 60 times, so results would be 60 different letters saved with 60 different filenames that are in the cells.
    I have manged to get to export the cells to the word document (1 time with bookmarks), but there is no loop that it will take the information from 60 cells and create 60 documents, and I need to make sure it will save 60 times with a different value of each cell. Really hope someone can help me with this as i am struggling for days now, please see my code:

    Sub CertGenerator()


    On Error GoTo errorHandler


    Dim wdApp As Word.Application
    Dim myDoc As Word.Document
    Dim mywdRange As Word.Range
    Dim Customer As Excel.Range
    Dim Deliverynr As Excel.Range
    Dim POnumber As Excel.Range


    Set wdApp = New Word.Application
    With wdApp
    .Visible = True
    .WindowState = wdWindowStateMaximize
    End With
    'Set the cell you want to copy'
    Set myDoc = wdApp.Documents.Add(Template:="C:\Test\Authorisationform.doc")
    Set Customer = Sheets("Sheet1").Range("A2")
    Set Deliverynr = Sheets("Sheet1").Range("D2")
    Set POnumber = Sheets("Sheet1").Range("E2")
    Set Colnr = Sheets("Sheet1").Range("D2")
    'Set the bookmark names'
    With myDoc.Bookmarks
    .Item("Customer").Range.InsertAfter Customer
    .Item("Deliverynr").Range.InsertAfter Deliverynr
    .Item("POnumber").Range.InsertAfter POnumber
    .Item("Colnr").Range.InsertAfter Colnr
    End With
    'How to save word document'
    With wdApp.ActiveDocument
    .SaveAs ("C:\Test\Authorisationform1.doc")
    .Close


    End With


    errorHandler:


    Set wdApp = Nothing
    Set myDoc = Nothing
    Set mywdRange = Nothing


    End Sub

    Really hope someone can help me as I am already struggling for days now, and it seems nobody want to answer me....

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Save as and creating loop for more word documents

    Welcome to the forum.

    We'd like to help you but first..

    Pls take some minutes to read forum rules and specially-in this case- rule#3
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Save as and creating loop for more word documents

    ... and #8.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Save as and creating loop for more word documents

    Thanks cytop.

    So.

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).


    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  5. #5
    Registered User
    Join Date
    01-21-2014
    Location
    Newhouse
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Save as and creating loop for more word documents

    Hi Cytop,

    Thank you for your email, and understand what you are trying to say, however the posts that I went through was not helping me or people stopped replying on it that is why I started a new Post, but I understand now that I am only getting remarks on how I have post my question instead of pushing me in the right direction.

    Cheers!

    Gr,

    JP

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro is creating two word documents
    By ERaasio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-03-2014, 01:27 PM
  2. [SOLVED] Macro for mail merge and save as word documents
    By aganesan99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-23-2013, 09:16 AM
  3. Performing Find loop on all Word documents in a folder, writing results to a Spreadsheet
    By fraanchtoast in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2012, 05:02 PM
  4. [SOLVED] Repeat macros in a loop and save as word files
    By amanduggal in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-07-2012, 08:39 AM
  5. Open and Save Word Documents via Excel
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-22-2010, 02:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1