Please help me out. MS Office Object Help 
Author Message
 Please help me out. MS Office Object Help

Question #1

I am using the following code to print out a word document:

Private Sub menuPrint_Click()
   Dim oWord As Object
   gDBName = App.Path & "\questionnaire.doc"

    On Error GoTo Command1_Click_Error

    Screen.MousePointer = vbHourglass
    Set oWord = CreateObject("Word.Application")

    With oWord
        .Documents.Open FileName:=(gDBName)
        .ActiveDocument.PrintOut
        .ActiveWindow.Close
    End With

    Set oWord = Nothing
    Screen.MousePointer = vbNormal
    Exit Sub
Command1_Click_Error:
    MsgBox "Error: " & Err & " - " & Error
    End
End Sub

The problem with the above code is that it comes back and asks you if want
to actually close the document or not because it is currently trying to
print.  Is there a way for the program to sit and pause long enough for the
document to finish printing before executing the "close" command?

Questions #2

I have the following code I am currently using:

Private Sub Command1_Click()
    Dim oAccess As Object
    gDBName = App.Path & "\Vipond_Example.mdb"

    On Error GoTo Command1_Click_Error

    Screen.MousePointer = vbHourglass
    Set oAccess = CreateObject("Access.Application")

    With oAccess
        .OpenCurrentDatabase (gDBName)
        .DoCmd.OpenReport "01"
    End With

    Set oAccess = Nothing
    Screen.MousePointer = vbNormal
    Exit Sub
Command1_Click_Error:
    MsgBox "Error: " & Err & " - " & Error
    End

End Sub

The problem with the above is that the database remains open.  What is the
command in Access to close the active document and window?

Question #3

Is there a good book that gives me all these commands or that I could
reference without having to bug you guys all the time?



Sat, 08 Mar 2003 03:00:00 GMT  
 Please help me out. MS Office Object Help
Question #1:

Try this:~

Private Sub WordSample()
Dim oWord As Word.Application

    Set oWord = New Word.Application

    With oWord

        '// Set the visible property to false, if you want to
        .Visible = False

        '// Open up your document
        .Documents.Open FileName:="c:\stuff.doc"

        '// Print the document, setting the Background option to true.
        '// The print is then a backgroundtask
        .ActiveDocument.PrintOut True

        '// As the print is in the background you can close the
        '// document and destroy the instance of word.
        .ActiveWindow.Close

    End With

    Set oWord = Nothing

End Sub

Question #2:

you could try :~

'// Closes the database for you.
oAccess.CloseCurrentDatabase

'// Now you can destroy the Access object.
Set oAccess = Nothing

Question #3:

Can't actually recommend any books as such but you should goto:

http://msdn.microsoft.com/office/

They have a very comprehensive site with sample code, tutorials etc.
I've never really needed anything else when I'm working with office.

Phil.



Quote:
> Question #1

> I am using the following code to print out a word document:

> Private Sub menuPrint_Click()
>    Dim oWord As Object
>    gDBName = App.Path & "\questionnaire.doc"

>     On Error GoTo Command1_Click_Error

>     Screen.MousePointer = vbHourglass
>     Set oWord = CreateObject("Word.Application")

>     With oWord
>         .Documents.Open FileName:=(gDBName)
>         .ActiveDocument.PrintOut
>         .ActiveWindow.Close
>     End With

>     Set oWord = Nothing
>     Screen.MousePointer = vbNormal
>     Exit Sub
> Command1_Click_Error:
>     MsgBox "Error: " & Err & " - " & Error
>     End
> End Sub

> The problem with the above code is that it comes back and asks you if
want
> to actually close the document or not because it is currently trying
to
> print.  Is there a way for the program to sit and pause long enough
for the
> document to finish printing before executing the "close" command?

> Questions #2

> I have the following code I am currently using:

> Private Sub Command1_Click()
>     Dim oAccess As Object
>     gDBName = App.Path & "\Vipond_Example.mdb"

>     On Error GoTo Command1_Click_Error

>     Screen.MousePointer = vbHourglass
>     Set oAccess = CreateObject("Access.Application")

>     With oAccess
>         .OpenCurrentDatabase (gDBName)
>         .DoCmd.OpenReport "01"
>     End With

>     Set oAccess = Nothing
>     Screen.MousePointer = vbNormal
>     Exit Sub
> Command1_Click_Error:
>     MsgBox "Error: " & Err & " - " & Error
>     End

> End Sub

> The problem with the above is that the database remains open.  What
is the
> command in Access to close the active document and window?

> Question #3

> Is there a good book that gives me all these commands or that I could
> reference without having to bug you guys all the time?

Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 08 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. Office 2000/ Office 97 Help Me please!

3. Need help automatically selecting MS Outlook Object Library in VB -please

4. MS Office Object Help - Please HELP, Program almost done!

5. Please help me out. MS Office Object Help.

6. PLEASE HELP PLEASE HELP PLEASE HELP

7. Need help with time outs

8. MS Office Dev - Consulting rate? Help

9. Problems with Ms Office VB Help app ?

10. HELP: MS Office VBA access to key events

11. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

12. Help with MS Office graphics filters

 

 
Powered by phpBB® Forum Software