Save just part of the document

P

Peter KNAP

Hi wise people.

I created form with macros and some UserForms for filling form fields.

This form have a lot of pages so I would like to add the button to UserForm
for saveing only special part of document (for example pages 3 to 6) since no
all pages are in some cases necessary and could cause misunderstandings. Does
VBA give possibility for creating macro for something like that?

many thanks

Peter.
 
D

Doug Robbins - Word MVP

Yes, except that "pages" is a bit undefined in that the layout of the pages
will depend upon the printer that is active in Word. I imagine that in your
case though, there may be some other way to define exactly what part of the
document it is that you want to save as a file by itself..

If you provide more information, it will be pretty straightforward to come
up with the necessary code.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter KNAP

I have form where 9 sections are created.
every section belongs to special kind of case I am deling with.
So if user select case 1, UserForm ask him to fill in only FormFields
belonging to this section and at the end is macro for printing only filled
pages . if user need to use case 2 macro leads him through formfields for
this section etc....
It could be made every section in single separate document but the goal is
to have all the cases in one template.
P.

„Doug Robbins - Word MVP" napísal (napísala):
 
D

Doug Robbins - Word MVP

OK, Sections we can work with. If you can determine the number of the
Section that you want to save as a separate document, you can use:

Dim i As Long
i = [the number of the section that you want to save]
Dim source As Document, target As Document
Set source = ActiveDocument
Set target = Documents.Add
target.Range.FormattedText = source.Sections(i).Range.FormattedText
target.SaveAs "Drive:\Path\Filename"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter KNAP

Thank you.
it works well however 1 problem occurs. How to set up path where to save
document. you know this form will be used by different paople with
diffferent configuration of PC ( some of them don´t have admin access, they
are just users) . is it possible to write some "universal path" which will
be useable for all ?

And one more question.
could you recommend some good author / book for learning VBA to me please? I
find very usefull to comunicate with online help but it is also qiute slow
and I am as keen as mustard for programming.

regards.
peter

„Doug Robbins - Word MVP" napísal (napísala):
OK, Sections we can work with. If you can determine the number of the
Section that you want to save as a separate document, you can use:

Dim i As Long
i = [the number of the section that you want to save]
Dim source As Document, target As Document
Set source = ActiveDocument
Set target = Documents.Add
target.Range.FormattedText = source.Sections(i).Range.FormattedText
target.SaveAs "Drive:\Path\Filename"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Peter KNAP said:
I have form where 9 sections are created.
every section belongs to special kind of case I am deling with.
So if user select case 1, UserForm ask him to fill in only FormFields
belonging to this section and at the end is macro for printing only filled
pages . if user need to use case 2 macro leads him through formfields for
this section etc....
It could be made every section in single separate document but the goal is
to have all the cases in one template.
P.

"Doug Robbins - Word MVP" napísal (napísala):
 
D

Doug Robbins - Word MVP

If you do not specify the drive and the path, the file will be saved in the
default documnet folder that is defined under Tools>Options>File Locations.

As far as books to learn VBA, I cannot really recommend any as I have never
read any. I would suggest however that you take a look at the article
"Getting To Grips With VBA Basics In 15 Minutes" at:

http://www.word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

and at other information on that site.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Peter KNAP said:
Thank you.
it works well however 1 problem occurs. How to set up path where to save
document. you know this form will be used by different paople with
diffferent configuration of PC ( some of them don´t have admin access,
they
are just users) . is it possible to write some "universal path" which
will
be useable for all ?

And one more question.
could you recommend some good author / book for learning VBA to me please?
I
find very usefull to comunicate with online help but it is also qiute slow
and I am as keen as mustard for programming.

regards.
peter

"Doug Robbins - Word MVP" napísal (napísala):
OK, Sections we can work with. If you can determine the number of the
Section that you want to save as a separate document, you can use:

Dim i As Long
i = [the number of the section that you want to save]
Dim source As Document, target As Document
Set source = ActiveDocument
Set target = Documents.Add
target.Range.FormattedText = source.Sections(i).Range.FormattedText
target.SaveAs "Drive:\Path\Filename"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Peter KNAP said:
I have form where 9 sections are created.
every section belongs to special kind of case I am deling with.
So if user select case 1, UserForm ask him to fill in only FormFields
belonging to this section and at the end is macro for printing only
filled
pages . if user need to use case 2 macro leads him through formfields
for
this section etc....
It could be made every section in single separate document but the goal
is
to have all the cases in one template.
P.

"Doug Robbins - Word MVP" napísal (napísala):

Yes, except that "pages" is a bit undefined in that the layout of the
pages
will depend upon the printer that is active in Word. I imagine that
in
your
case though, there may be some other way to define exactly what part
of
the
document it is that you want to save as a file by itself..

If you provide more information, it will be pretty straightforward to
come
up with the necessary code.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Hi wise people.

I created form with macros and some UserForms for filling form
fields.

This form have a lot of pages so I would like to add the button to
UserForm
for saveing only special part of document (for example pages 3 to 6)
since
no
all pages are in some cases necessary and could cause
misunderstandings.
Does
VBA give possibility for creating macro for something like that?

many thanks

Peter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top