Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Dynamic Word Doc Generation, Porting VBA to ASP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Enrique Rojas - 27 Dec 2006 20:53 GMT
Hello,

I have VBA code from an  Access Form that I am porting over to ASP.

What the code does is takes a document template and inserts data tables
with values taken from an Access Database.

What I need to do have this code work in ASP. Generate a client side
word document based on the data in the database.

So far I have been able to port most of the code over. The Template
opens and values are being read from the database. However I run into a
problem with these lines.

objw.Selection.HomeKey Unit: = wdLine

and later

myTable.Cell(1, 1).Merge MergeTo:=myTable.Cell(2, 1)
myTable.Cell(2, 10).Merge MergeTo:=myTable.Cell(1, 10)
myTable.Cell(1, 2).Merge MergeTo:=myTable.Cell(1, 9)

Seems like commands with ":=" are no liked in ASP

I have been searching the internet for a solution where I can reword
that line but found nothing.

I have been using an ASP server called Baby ASP.

Can anyone confirm that these lines of code actualy do work in ASP.

Looking forward to a response.

Thank you.
Doug Robbins - Word MVP - 27 Dec 2006 21:46 GMT
I am not sure that this will overcome your problem, but in VBA,

Selection.HomeKey wdLine

can be used in place of

Selection.HomeKey Unit: = wdLine

and maybe you will need to use the Selection object for the cell merges

MyTable.Cell(1, 1).Range.Select
Selection.Extend
Selection.MoveDown wdLine, 1
Selection.Cells.Merge

Signature

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

> Hello,
>
[quoted text clipped - 30 lines]
>
> Thank you.
Enrique Rojas - 28 Dec 2006 19:26 GMT
Thank you all for your suggestions.

I ran the code with your suggestions.

However the line  "Selection.HomeKey wdLine" cause caused an error when
word document was being generated.

compared to before the line "Selection.HomeKey Unit: = wdLine" the
server just did not want to run at all. The word document did not even
open.

I just commented it out for now. The table merge suggestions were great
and are working fine.

Thanks to all

> I am not sure that this will overcome your problem, but in VBA,
>
[quoted text clipped - 53 lines]
> >
> > Thank you.
Helmut Weber - 28 Dec 2006 20:11 GMT
Hi Enrique,

if you want to put the cursor at the beginning
of the doc, for whatever reasons, you may use
activedocument.range(0,0).select

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Doug Robbins - Word MVP - 29 Dec 2006 09:05 GMT
See Cindy's response.

Signature

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

> Thank you all for your suggestions.
>
[quoted text clipped - 69 lines]
>> >
>> > Thank you.
Helmut Weber - 27 Dec 2006 23:16 GMT
Hi Enrique,

have a look at this one:

oTbl.Cell(1, 1).Merge oTbl.Cell(2, 1)
oTbl.Cell(2, 10).Merge oTbl.Cell(1, 10)
oTbl.Cell(1, 2).Merge oTbl.Cell(1, 9)

ok, if it works for you,
but you may run into trouble by trying to
access table cells by rowindex and columnindex
after having merged certain cells: Error 5941

In that case, keep very precisely track
of the number of cells you merge and which
and use something like:

oTbl.Range.Cells(1).Merge oTbl.Range.Cells(4)

There may still be other ways,
and of course, there is Doug's method, too.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Cindy M. - 28 Dec 2006 09:49 GMT
Hi Enrique,

> Seems like commands with ":=" are no liked in ASP
>  
> I have been searching the internet for a solution where I can reword
> that line but found nothing.

When that's the case, then you have no choice but to type out every
parameter a method or property requires. For example, HomeKey has two
parameters:

Selection.HomeKey wdLine, false

Note that depending on the programming language, you might have to put
the parameters in parentheses

myTable.Cell(1, 1).Merge(myTable.Cell(1,3))

If you check Word's VBA Help for a method you're having problems with
you can see a list of the parameters. Parameters marked as [Optional]
can be left out; since optional parameters are always at the end, if
you don't need any of them, you can simply stop. So, HomeKey could
also be
   Selection.HomeKey wdLine

because the second argument (Extend) is optional. Here's an example of
a method (fantasy, it doesn't exist) that has five parameters. None
are required, but it's the fifth one you want to use. In that case,
you have to use "empty commas" for the others in order to get to the
fifth one:

myMethod(,,,,true)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.