Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenPrintCloseExcel in access

Status
Not open for further replies.

bw2601

Technical User
Dec 16, 2004
29
US
I am trying to write a module that will open excel, print the file and close the program by just pressing a button on switchboard manager, however i am having a really hard time getting started.

can someone please give me some ideas and pointers

thanks
 
bw2601,

Open the VBA help text and seach for the "Sendkeys" function. Look at the example. It opens windows calculator.

Modify to suit your needs.

Hope this helps..

Good Luck...


 
Thank you for your help, I guess it is just me, i don't know VBA that well, so my coding is really wrong, but i'll keep plugging along.

thanks again
 
Perhaps something like this might be helpful:
(Be sure to reference MS Excel 10.0 Object Library in tools-references)
Private Sub PassVariable()
On Error GoTo Err_Routine

Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet

Set objXL = New Excel.Application
Set objWkb = objXL.Workbooks.Open("C:\Documents and Settings\YourFileName.xls")

Set objSht = objWkb.Worksheets("SheetName")
objSht.PrintPreview

DoEvents

objWkb.Save
objXL.Quit

Set objSht = Nothing
Set objWkb = Nothing
Set objSht = Nothing

Exit Sub
Err_Routine:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub
 
In order for a VBA macro to work, Don't you have to have that Excel file open? It sounds like you need a simple VB program that is aside from Excel. Have you tried to "Record a New Macro"? When you record a new macro you do the events you wish for the Macro to do for you. Tryit and see if it works...

LF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top