goofy78270
Well-known Member
- Joined
- May 16, 2007
- Messages
- 555
I currently have a macro that exports all worksheets in a workbook to a word document. I would like to add a javascript function to the document and between each page to offer a slide effect to the word document before publishing the document as a web file.
Here is the script that I would add at the beginning of the file:
Then I would simple add an anchor tag to each section around each page as is is imported to the word document.
Has anyone done anything like this? Should I be looking in another direction for such a project?
Here is the script that I would add at the beginning of the file:
Code:
<TABLE><TBODY><TR><TD class=number><CODE>01</CODE></TD><TD class=content><CODE class="jscript keyword">function</CODE> <CODE class="jscript plain">doSlide(id){ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>02</CODE></TD><TD class=content><CODE class="jscript plain">timeToSlide = 50; </CODE><CODE class="jscript comments">// in milliseconds </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>03</CODE></TD><TD class=content><CODE class="jscript plain">obj = document.getElementById(id); </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>04</CODE></TD><TD class=content><CODE class="jscript keyword">if</CODE><CODE class="jscript plain">(obj.style.display == </CODE><CODE class="jscript string">"none"</CODE><CODE class="jscript plain">){ </CODE><CODE class="jscript comments">// if it's allready hidden we slide it down </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>05</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.visibility = </CODE><CODE class="jscript string">"hidden"</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>06</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.display = </CODE><CODE class="jscript string">"block"</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>07</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">height = obj.offsetHeight; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>08</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.height=</CODE><CODE class="jscript string">"0px"</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>09</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.visibility = </CODE><CODE class="jscript string">"visible"</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>10</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">slideDown(obj,0,height,Math.ceil(height/timeToSlide)); </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>11</CODE></TD><TD class=content><CODE class="jscript plain">} </CODE><CODE class="jscript keyword">else</CODE> <CODE class="jscript plain">{ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>12</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">slideUp(obj,Math.ceil(obj.offsetHeight/timeToSlide),obj.offsetHeight); </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>13</CODE></TD><TD class=content><CODE class="jscript plain">} </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>14</CODE></TD><TD class=content><CODE class="jscript plain">} </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>15</CODE></TD><TD class=content><CODE class=spaces> </CODE> </TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>16</CODE></TD><TD class=content><CODE class="jscript keyword">function</CODE> <CODE class="jscript plain">slideDown(obj,offset,full,px){ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>17</CODE></TD><TD class=content><CODE class="jscript keyword">if</CODE><CODE class="jscript plain">(offset < full){ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>18</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.height = offset+</CODE><CODE class="jscript string">"px"</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>19</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">offset=offset+px; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>20</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">setTimeout((</CODE><CODE class="jscript keyword">function</CODE><CODE class="jscript plain">(){slideDown(obj,offset,full,px);}),1); </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>21</CODE></TD><TD class=content><CODE class="jscript plain">} </CODE><CODE class="jscript keyword">else</CODE> <CODE class="jscript plain">{ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>22</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.height = full+</CODE><CODE class="jscript string">"px"</CODE><CODE class="jscript plain">; </CODE><CODE class="jscript comments">//If the data inside is updated on runtime you can use auto instead... </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>23</CODE></TD><TD class=content><CODE class="jscript plain">} </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>24</CODE></TD><TD class=content><CODE class="jscript plain">} </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>25</CODE></TD><TD class=content><CODE class=spaces> </CODE> </TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>26</CODE></TD><TD class=content><CODE class="jscript keyword">function</CODE> <CODE class="jscript plain">slideUp(obj,px,full){ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>27</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript keyword">if</CODE><CODE class="jscript plain">((obj.offsetHeight-px) > 0){ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>28</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.height = obj.offsetHeight-px+</CODE><CODE class="jscript string">"px"</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>29</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">setTimeout((</CODE><CODE class="jscript keyword">function</CODE><CODE class="jscript plain">(){slideUp(obj,px,full);}),1); </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>30</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">} </CODE><CODE class="jscript keyword">else</CODE> <CODE class="jscript plain">{ </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>31</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.height=full+</CODE><CODE class="jscript string">"px"</CODE><CODE class="jscript plain">; </CODE><CODE class="jscript comments">// we reset the height if we were to slide it back down </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>32</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">obj.style.display = </CODE><CODE class="jscript string">'none'</CODE><CODE class="jscript plain">; </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>33</CODE></TD><TD class=content><CODE class=spaces> </CODE><CODE class="jscript plain">} </CODE></TD></TR></TBODY></TABLE>
<TABLE><TBODY><TR><TD class=number><CODE>34</CODE></TD><TD class=content><CODE class="jscript plain">}</CODE></TD></TR></TBODY></TABLE>
Then I would simple add an anchor tag to each section around each page as is is imported to the word document.
Has anyone done anything like this? Should I be looking in another direction for such a project?