#16
|
|||
|
|||
RE:
Hmm, nope...but Im going to try changing the directory and see if it works there....Ill let you know if this works right away.
Let me ask you this....and you can tell me your thoughts...The first part of the code (the first sub routine) is supposed to split out each paragraph number. The second part of the code (the part you did) - is supposed to insert the images to the pdfs that are going to be created. Since there are two macro's in two different sub's would it be better if they were combined as one macro? Do you think that could have any reason why this works, then fails? |
#17
|
|||
|
|||
RE:
Hey Macropod,
Alrighty, in response to this, the answer is, I deleted the .pdf's I had previously created with the Macro. I re-ran the Macro, it did what it was supposed to. So then I went back into the directory, deleted the pdfs once again for a fresh start, then I re-ran the Macro and it started opening blank Word documents again... Weird and interesting huh? |
#18
|
||||
|
||||
Did you edit the macro code to point to the correct folder in each case?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#19
|
|||
|
|||
RE:
Yep, I sure did. See the thing is, I can make it work. But when it starts to fail is when - I delete the .pdf's in the directory, then try and execute the Macro a second time.
When executing the Macro a second time, its not that the Macro doesn't work, it just starts to do weird things, like copy the entire word document, to a new Word document and close the original file. For example, say the original document which has the content is called test.docm, when the Macro is executed a second time it copies all the content from test.docm to a new Word document such as "document 5.docm" then the script wants to delete everything in test.docm and prompts me to save the changes to test.docm Of course I click, "do not save changes". But Im not sure why its doing this. |
#20
|
|||
|
|||
RE:
Hey There,
I took some screenshots for you to view as well: template.jpg example2.JPG document1.jpg Screenshots: 3007 - template.jpg - this screenshot is of the original document - as you can see the content has been deleted from it. 3008 - example2.jpg - this screenshot is a shot of my task bar, as you can see I have the original document "template.docm" open - but the script has created "Document1.doc" 3009 - Document1.jpg - this is a screenshot of the new document the script is creating, as you can see it has all the content from my original document, template.docm Just wanted to give some visual aids as to what is happening incase it helps. |
#21
|
||||
|
||||
Quote:
Code:
Sub Splitter() Dim numlets As Long, Counter As Long, sPath As String, DocName As String numlets = ActiveDocument.Sections.Count If numlets > 1 Then numlets = numlets - 1 sPath = "k:\test\images\" For Counter = 1 To numlets DocName = sPath & Format(Counter, "000") ActiveDocument.Sections.First.Range.Cut Documents.Add With ActiveDocument.Range .Paste .Characters.First = vbNullString .SaveAs2 FileName:=DocName, FileFormat:=wdFormatPDF .Close End With Next Counter End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#22
|
||||
|
||||
Your post #20 suggests you're running your 'Splitter' macro, not the 'InsertPicsToPDF' macro I provided. Your 'Splitter' macro has code for cutting content - which would cut the content out of your 'template' document - my 'InsertPicsToPDF' macro has no code for cutting content.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#23
|
|||
|
|||
RE:
Hey Macropod,
Thanks for the response. You are absolutely right. I want the paragraph labeled 001 - to have the corresponding image inserted above the paragraph (as the code does) - then I want paragraph 1 split out and saved as 001.pdf then I want paragraph 2 to have have its corresponding image inserted, then split out and saved as a pdf called 002. and so... I think your right, I think Im executing this Macro and on the first go-around it is inserting the images, then splitting out the individual pdfs, as its supposed to. But then when I delete all the pds that were created, and all the images out of the document to try a second test of the document, only one out of the two Macros are being executed instead of both at the same time. So does the Macro need to be combined as one instead of two seperate macros? Quote:
|
#24
|
||||
|
||||
Why are you bothering with your 'Splitter' macro at all? The 'InsertPicsToPDF' macro I provided makes no use of it for the first round, so why would you expect it to do so for the second?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#25
|
|||
|
|||
RE:
Hey Macropod,
Thanks for the response once again... To answer your question, that is because the InsertPicstoPDF Macro doesn't split out the paragraph and image and save it as a pdf. Basically this is the underlying problem Im trying to solve...We get a list of employee descriptions submitted by corporate communications. Those descriptions come in paragraphs, and the paragraphs have labels such as 001, 002, 003, 004, 005, 006 and so on. In my k:\ directory I provided is where images of all the employees reside. The images of the employees are also numbered 001, 002, 003, 004, 005. So the macro is supposed to be inserted on the word document we get from communications, and once executed the images are supposed to get inserted above the paragraphs. Once the images are inserted above each paragraph each paragraph and its image have to be saved seperately. So, image 002 and paragraph 002, will be saved as 002.pdf Image 003 and paragraph 003, will be saved as 003.pdf and so on. So thats why I have the splitter macro in there...Once the images are inserted on the word document its supposed to split out each paragraph. |
#26
|
||||
|
||||
Not so! That's exactly what it does.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#27
|
|||
|
|||
RE:
Look Im not trying to argue my friend, Im just trying to make this work. And again, it does work, its just that if I run it a second time, that's where it starts erroring.
Its not your VBA code, its probably something wrong on my end, like a firewall issue, or something not being cleared...Im not arguing with you sorry if it seemed that way. The code absolutely does work, my vba editor just starts to error on the second go-around - which Ill have to figure out why thats happening. Although I just noticed....If I stop saving in my k:\ directory and do it on a folder on my desktop. It works perfectly fine ...So Ill just have to do it that way for now. Thanks for all your help though Macropod! I really appreciate all the effort in trying to help me get through this!...I will mark this topic solved again. Have a good one. |
#28
|
||||
|
||||
Let me put it simply: your 'Splitter' macro contributes nothing to the process. The 'InsertPicsToPDF' macro does all that is required. It both inserts the images and saves them out to a new file.
The problems you are getting are caused solely by running your 'Splitter' macro, not by any firewall or 'other issue'. That macro is predicated on the document it is run on having a separate Section for each numbered paragraph. Your document (or at least the one you attached to post #1 in this thread) is not like that - it has all of them in one section. So, when your 'Splitter' macro tries to cut content on a Section by Section basis, it simply cuts all of the content from the source document and pastes it into the output document. If you want to be able to generate a new set of pdfs, simply close the source document without saving, then re-open it and re-run the 'InsertPicsToPDF' macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserted PDFs become Pixelated in Powerpoint | fongchun | PowerPoint | 0 | 11-26-2012 06:24 PM |
My Word 2007 doesnt display PDFs correctly | mattk561 | Word | 8 | 10-31-2012 08:04 PM |
Embedding PDFs in MS Word 2010 | chitownbillj | Word | 1 | 06-30-2012 12:01 AM |
Creating High Quality PDFs from Word 2010 | BrazzellMarketing | Word | 11 | 01-27-2012 01:06 PM |
Converting Powerpoint into Fully Accessable PDFs | KCD123 | PowerPoint | 4 | 09-28-2011 10:03 AM |