Jump to content
Sign in to follow this  
Guest Andrew

Geek advise

Recommended Posts

Guest Andrew

Anyone have any info on interacting with the MS Word API? I'd like to control a mail merge from a DB with my VB app - I figured i'd use Words printing abilities and mail merge sh*t rather that write my own software to print and mail merge.

Any ideas?

DB is MDB and I connect to it using DAO. Have seen apps integrate with Word in the past giving it SQL commands.

Share this post


Link to post
Share on other sites

Explain to me what you're trying to do?

My initial advise would be to not use Word for anything but low level stuff

Share this post


Link to post
Share on other sites
Guest Andrew

basically i have a VB app - and it spews out a report

And usually I would output to a txt file HTML code and make an HTML report - but in this case I need to print - and its hard to do printer formatting when doing a webpage.

So - i'd like to output some fields from my program - into a letter - and print a batch of letters.

e.g usually this type of output to update the website - but now i want to make a printable letter

   Dim i As Integer
    
    Open App.Path & "\index.html" For Output As #1
     
     'put pretty PWAL logo up top + HTML formatting sh*t
    
    Print #1, "<html>"
    Print #1, "<head>"
    Print #1, "<title>Premium Wholesale Auctions LTD - Dealer Wholesale List. Updated " & Date & "</title>"
    Print #1, "</head>"
    Print #1, "<body>"
    Print #1, "<p align=""center""><img border=""0"" src=""PWA_logo_2col.jpg"" width=""640"" height=""172""></p>"
    Print #1, " "
    Print #1, "<font face=""Tahoma"" size=""1"">"
    Print #1, "<p align=""center""><a href=""http://www.premium-auctions.co.nz/legend.html""><b> Click here to view extras legend </p></b></a>"
    Print #1,
    Print #1, "<p align=""center""><b> Contact: Stephen Thwaites 021 687 702 OR Melanie McGovern 021 468 808 </p></b>"
    
    'initial table formatting - chuck in table headings
    Print #1, "<font face=""Tahoma"" size=""1"">"
    Print #1, "<div align=""center""> <table border=""1"" cellspacing=""1"">" 'width=""100%""
    Print #1, "<tr>"
    Print #1, "<td>Stock</td><td>Year</td><td>Colour</td><td>Make</td><td>Model</td><td>Fuel</td><td>Odo</td>";
    Print #1, "<td>Rating</td><td>Other</td><td>Body</td><td>Trans</td><td>Doors</td><td>Retail</td><td>Pics</td>";
    Print #1, "</tr>"

    i = 1
    Rs.MoveFirst
    Rs.MoveNext 'to get rid of the ugly blank line at the beg. of the DB
    
    'load a whole line into the table - then move to next line
    While Rs.EOF = False
        Print #1, "<tr>"
        Print #1, "<td>" & Rs!StockNum & "</td><td>" & Rs!Year & "</td><td>" & Rs!Colour & "</td><td>" & Rs!Make & "</td>";
        Print #1, "<td>" & Rs!Model & "</td><td>" & Rs!Fuel & "</td><td>" & Rs!Odo & "</td>";
        Print #1, "<td>" & Rs!Rating & "</td><td>" & Rs!Options & "</td><td>" & Rs!Body & "</td><td>" & Rs!Trans & "</td>";
        Print #1, "<td>" & Rs!Doors & "</td><td>" & Rs!Retail & "</td>";
        
        
        Print #1, "<td>";
        While i < 4
            Print #1, "<a href=""";
            Print #1, Rs!StockNum & "-" & i & ".JPG"""
            Print #1, ">" & i & " "
            Print #1, "</a>"
            i = i + 1
        Wend
        Print #1, "</td>";
                  
        Print #1, "</tr>" 'newline
        Rs.MoveNext 'new record
        i = 1
        
    Wend
        
    Close #1
    
    'Call batch file to begin pictures/webupload
    ShellExecute Me.hwnd, "open", "J:\sundry\webprem.bat", 0&, 0&, 1

Share this post


Link to post
Share on other sites

I find your original method easier, what's hard about printer formatting?

Share this post


Link to post
Share on other sites

Oh. My. God.

And I thought reading music sheets for drums was complicated.

Edited by BMW POWER

Share this post


Link to post
Share on other sites

I see your problem. ..

your VB app outputs an html page right .. ??

Printing that from word would just give you the code and not the formatted text.

correct me if i'm wrong but you want to strip the hmtl and just print the text?

if thats the case .. you should be able to setup a macro (in word) to stript the html code and leave you with the plain txt.

there are much eaiser ways to output your date tho, ahh ... here's the geek .. mu ha ha .. are you pulling data from a database?, can you change your vb script or is it compiled? .. so many questions ...

Looking at your code it seems like you are trying to output a list from a database. you can send html via outlook and have it show up on the users end as a page but you need absolute links.

If you cant modify your vb script .. you may need to look at doing it a different way... it all depends on the backend DB you are running, writing code to extact your info isn't that hard.

If you need help my friend .. I do this sh*t for a living :) .. get in touch and we can see what we can do :)

Edited by WarlockNZ

Share this post


Link to post
Share on other sites

record us a beat, emma. and stick it on the net.

I haven't got a drumset at home.

I drum at school. But I do get tabs off the net and re-do the drums on my drum machine on the computer. So far I've done a bit of Rammstein - Mutter.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...