J
james3mg
Hello, all!
I'm trying to write a program which will allow the user to select a group of
pictures, insert those pictures in a .docx document, and save the document in
the same folder as the pictures.
I have created a .docx document which will serve as my starting point: it
has only
_rels\.rels
app.xml and core.xml under docProps\
[Content_Types].xml
document.xml, header1.xml, footer1.xml under word\
and word\_rels\document.xml.rels
in it. I have gone through and stripped out the sidR tags so that word will
create them new each time (causing them to be unique and correct through
Word's system) as well as some unnecessary tags. (i.e. tags referring to
broken relationships, since I don't need files like settings.xml,
fontmap.xml, etc, as Word will create the appropriate files upon first save).
The document.xml file under word\ references the header and footer I have
created, establishes the columns and contains the tags for the table and text
I want to accompany each picture inserted. I have also identified all the
tags I need for the insertion of the pictures. In this way, I will be able
to have my program copy most of the core files into a new .docx file, then
create on-the-fly the word\_rels\document.rels directory of pictures.
Finally, it will create the document.xml file itself by writing the tags that
don't change, then copying the block of code for the table, picture and text
for each picture desired in the correct place.
My only problem is that I don't want the paths to the inserted pictures to
be absolute paths, nor do I want the pictures to be embedded within the
document. I'm using tags such as
<Relationship Id="rId6"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="file:///c:\whatever\moo.JPG" TargetMode="External"/>
to link the pictures into the document, but I haven't found a way to make
the paths relative to the .docx file. Simply referencing Target="moo.JPG",
or "..\moo.JPG" or "file:///moo.JPG" etc, results in everybody's favorite red
"x" icon within the document.
The reason I want them to be relative is that the pictures are of particular
jobs, initially in the active jobs directory on our network, but will
eventually get moved into the archived jobs directory. Since all the linked
pictures are in the same directory as the .docx file itself, I want to figure
out how to change the target tag so that word looks for the filename in the
same directory as the currently open file. That way, when the job gets moved
to the inactive jobs directory, the pictures and word document will remain
together, simply in a new root directory, and the links (relationship) will
not be broken, as they would be if absolute paths were used, since the path
will change when the project is moved.
If this should be deleted and reposted elsewhere, please inform me where.
This was the best-fitting discussion group I could find, and I have had very
poor luck finding information on the Word2007 xml tags themselves anywhere on
the internet, beyond the VERY basics such as at
http://msdn2.microsoft.com/en-us/li...eformat_walkthroughcreatingawordxmlformatfile
Thank you all for your help!
I'm trying to write a program which will allow the user to select a group of
pictures, insert those pictures in a .docx document, and save the document in
the same folder as the pictures.
I have created a .docx document which will serve as my starting point: it
has only
_rels\.rels
app.xml and core.xml under docProps\
[Content_Types].xml
document.xml, header1.xml, footer1.xml under word\
and word\_rels\document.xml.rels
in it. I have gone through and stripped out the sidR tags so that word will
create them new each time (causing them to be unique and correct through
Word's system) as well as some unnecessary tags. (i.e. tags referring to
broken relationships, since I don't need files like settings.xml,
fontmap.xml, etc, as Word will create the appropriate files upon first save).
The document.xml file under word\ references the header and footer I have
created, establishes the columns and contains the tags for the table and text
I want to accompany each picture inserted. I have also identified all the
tags I need for the insertion of the pictures. In this way, I will be able
to have my program copy most of the core files into a new .docx file, then
create on-the-fly the word\_rels\document.rels directory of pictures.
Finally, it will create the document.xml file itself by writing the tags that
don't change, then copying the block of code for the table, picture and text
for each picture desired in the correct place.
My only problem is that I don't want the paths to the inserted pictures to
be absolute paths, nor do I want the pictures to be embedded within the
document. I'm using tags such as
<Relationship Id="rId6"
Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="file:///c:\whatever\moo.JPG" TargetMode="External"/>
to link the pictures into the document, but I haven't found a way to make
the paths relative to the .docx file. Simply referencing Target="moo.JPG",
or "..\moo.JPG" or "file:///moo.JPG" etc, results in everybody's favorite red
"x" icon within the document.
The reason I want them to be relative is that the pictures are of particular
jobs, initially in the active jobs directory on our network, but will
eventually get moved into the archived jobs directory. Since all the linked
pictures are in the same directory as the .docx file itself, I want to figure
out how to change the target tag so that word looks for the filename in the
same directory as the currently open file. That way, when the job gets moved
to the inactive jobs directory, the pictures and word document will remain
together, simply in a new root directory, and the links (relationship) will
not be broken, as they would be if absolute paths were used, since the path
will change when the project is moved.
If this should be deleted and reposted elsewhere, please inform me where.
This was the best-fitting discussion group I could find, and I have had very
poor luck finding information on the Word2007 xml tags themselves anywhere on
the internet, beyond the VERY basics such as at
http://msdn2.microsoft.com/en-us/li...eformat_walkthroughcreatingawordxmlformatfile
Thank you all for your help!