Excel Closes, But Word Doesn't! And Word Won't Print!
Hello: My code needs to open Excel, populate a table with data, mail-merge that table with a Word document, and finally print the merged documents. I have two problems:
1) As the program finishes, Excel closes and is removed from the Task Manager's Processes list, but Word is not removed. I've tried the .Quit method for both (even accounting for Word's use of parameters), but "WINWORD.EXE" remains on the list even after "EXCEL.EXE" is removed. I also set my objects to Nothing in Class_Terminate, but still no luck - and putting the .Close/.Quit procedures under Class_Terminate gave me an error. I know Excel is working because the program is saving my .xls files, but I'm not sure about Word. Which leads to...
2) Obviously I'm only opening Word to merge the file - the text of the document itself never changes so it doesn't need to be saved, just linked to the data source (the Excel table just created). But I can't get Word to print! I set the .ActivePrinter property and used .PrintOut but no luck. What do I have wrong here? Thanks for any insight.
Jeff W. Owen, Little and Assoc., Inc. Beachwood, NJ
P.S. This code runs from within ArcMap, a digital-mapping software package. Hence all of the "ICommand"s and "IMap"s and such, the use of "ISelectionSet" to populate the Excel table, etc. All of the code pertaining to ArcMap works fine - it's mostly just the part at the end of the code relating to Word where there must be something I'm doing wrong.
Code:Option Explicit
Implements ICommand
Private m_pApp As IApplication Private m_pMxDoc As IMxDocument Private m_pMap As IMap Private m_pExt As IExtension Private m_pFeature As IFeature Private m_pFeatureLayer As IFeatureLayer Private m_pFeatureCursor As IFeatureCursor Private m_pFeatureSelection As IFeatureSelection Private m_pSelectionSet As ISelectionSet Private m_pFields As IFields Private m_pField As IField Private m_pRow As IRow Private m_pCursor As ICursor Private m_pQBLayer As IQueryByLayer Private m_pBitmap As IPictureDisp
Private m_pAppExcel As New Excel.Application Private m_pWorkbook As Excel.Workbook Private m_pWorksheet As Excel.Worksheet
Private m_pAppWord As New Word.Application Private m_pDocument As New Word.Document Private m_pMailMerge As MailMerge
Private Sub Class_Initialize() Set m_pBitmap = LoadResPicture(101, vbResBitmap) 'Button icon End Sub
Private Sub Class_Terminate() Set m_pApp = Nothing Set m_pMxDoc = Nothing Set m_pMap = Nothing Set m_pExt = Nothing Set m_pFeature = Nothing Set m_pFeatureLayer = Nothing Set m_pFeatureCursor = Nothing Set m_pFeatureSelection = Nothing Set m_pSelectionSet = Nothing Set m_pFields = Nothing Set m_pField = Nothing Set m_pRow = Nothing Set m_pCursor = Nothing Set m_pQBLayer = Nothing Set m_pBitmap = Nothing
Set m_pAppExcel = Nothing Set m_pWorkbook = Nothing Set m_pWorksheet = Nothing
Set m_pAppWord = Nothing Set m_pDocument = Nothing Set m_pMailMerge = Nothing End Sub ' 'ICommand members ' Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE ICommand_Bitmap = m_pBitmap End Property
Private Property Get ICommand_Caption() As String ICommand_Caption = "200' List" End Property Private Property Get ICommand_Category() As String ICommand_Category = "Extending ArcObjects" End Property
Private Property Get ICommand_Checked() As Boolean ICommand_Checked = False End Property
Private Property Get ICommand_Enabled() As Boolean ICommand_Enabled = True End Property
Private Property Get ICommand_HelpContextID() As Long
End Property
Private Property Get ICommand_HelpFile() As String
End Property
Private Property Get ICommand_Message() As String ICommand_Message = "Creates a 200' list for selected property and generates an Excel file (for mail merge)" End Property Private Property Get ICommand_Name() As String ICommand_Name = "ExtendingArcObjects_200FootList" End Property Private Property Get ICommand_Tooltip() As String ICommand_Tooltip = "Create a 200' list" End Property
Private Sub ICommand_OnCreate(ByVal hook As Object) Dim a As New UID Set m_pApp = hook a.Value = "CmdToolbarExt.clsLaunchExtension" Set m_pExt = m_pApp.FindExtensionByName("200FootListExtension") End Sub
Private Sub ICommand_OnClick() ''MAIN BUTTON Dim a As Long 'Field (i.e. column) value Dim b As Long 'b-d: counters Dim c As Long Dim d As Long Dim lMaxSize(8) As Long 'Width of each field Dim sValue As String 'Current record's value (string) Dim lHolder As Long 'Temp. field width value Dim sFieldName(8) As String Dim sBlock As String Dim sLot As String Dim sFirstRecord As String 'Holds IDNum of 1st selected record Dim sFileName As String sFieldName(0) = "IDNum" sFieldName(1) = "Block" sFieldName(2) = "Lot" sFieldName(3) = "FULLNAME" sFieldName(4) = "ADDRESS" sFieldName(5) = "CITY" sFieldName(6) = "STATE" sFieldName(7) = "ZIP" sFieldName(8) = "PROPLOC" Set m_pMxDoc = m_pApp.Document Set m_pMap = m_pMxDoc.FocusMap Set m_pFeatureLayer = m_pMxDoc.FocusMap.Layer(0) '!!Change to reflect name Set m_pFeatureSelection = m_pFeatureLayer ' of parcel layer!! Set m_pCursor = m_pFeatureLayer.Search(Nothing, False) 'Create Excel file name Call m_pFeatureSelection.SelectionSet.Search(Nothing, False, m_pFeatureCursor) Set m_pFeature = m_pFeatureCursor.NextFeature sFirstRecord = "Block" & m_pFeature.Value(m_pFeature.Fields.FindField("Block")) & "Lot" & _ m_pFeature.Value(m_pFeature.Fields.FindField("Lot")) Set m_pQBLayer = New QueryByLayer With m_pQBLayer 'Select all parcels within 200 feet Set .ByLayer = m_pFeatureLayer ' of the selected parcel Set .FromLayer = m_pFeatureLayer .BufferDistance = 200 .BufferUnits = esriFeet .ResultType = esriSelectionResultAdd .LayerSelectionMethod = esriLayerSelectWithinADistance .UseSelectedFeatures = True Set m_pFeatureSelection.SelectionSet = .Select End With
Set m_pSelectionSet = m_pFeatureSelection.SelectionSet Call m_pSelectionSet.Search(Nothing, False, m_pCursor)
Set m_pFields = m_pCursor.Fields Set m_pRow = m_pCursor.NextRow
m_pMxDoc.ActiveView.Refresh '*******************************mostly ArcMap code above this line************ '*******************************mostly VBA code below this line*************** Set m_pAppExcel = CreateObject("excel.application") 'Create Excel instance Set m_pWorkbook = m_pAppExcel.Workbooks.Add 'Create workbook/worksheet Set m_pWorksheet = m_pWorkbook.Sheets.Add(After:=m_pWorkbook.Sheets(m_pWorkbook.Sheets.Count)) Cells(1, 1).Value = "IDNumber" 'Field names Cells(1, 2).Value = "Block" Cells(1, 3).Value = "Lot" Cells(1, 4).Value = "Name" Cells(1, 5).Value = "Address" Cells(1, 6).Value = "City" Cells(1, 7).Value = "State" Cells(1, 8).Value = "ZIP" Cells(1, 9).Value = "Property Loc." m_pAppExcel.DisplayAlerts = False 'Kill first three sheets Worksheets("Sheet1").Delete Worksheets("Sheet2").Delete Worksheets("Sheet3").Delete m_pAppExcel.DisplayAlerts = True m_pWorksheet.Activate m_pWorksheet.Name = "200 Foot List" m_pWorksheet.Rows(1).Font.Bold = True c = 1 d = 1 Do While Not m_pRow Is Nothing 'Grab values from selection set c = c + 1 For b = 0 To 8 a = m_pFields.FindField(sFieldName(b)) m_pWorksheet.Cells(c, d).Value = m_pRow.Value(a) 'Write value to record sValue = m_pRow.Value(a) If c = 2 Then 'Find the longest entry in each field lMaxSize(b) = Len(sValue) Else lHolder = Len(sValue) If lHolder > lMaxSize(b) Then lMaxSize(b) = lHolder End If End If d = d + 1 Next b Set m_pRow = m_pCursor.NextRow d = 1 Loop If lMaxSize(0) < 10 Then lMaxSize(0) = 10 'Minimum widths for fields If lMaxSize(1) < 6 Then lMaxSize(1) = 6 If lMaxSize(2) < 4 Then lMaxSize(2) = 4 If lMaxSize(3) < 6 Then lMaxSize(3) = 6 If lMaxSize(4) < 8 Then lMaxSize(4) = 8 If lMaxSize(5) < 4 Then lMaxSize(5) = 4 If lMaxSize(7) < 6 Then lMaxSize(7) = 6 If lMaxSize(8) < 13 Then lMaxSize(8) = 13 m_pWorksheet.Columns("A").ColumnWidth = lMaxSize(0) 'Set field widths m_pWorksheet.Columns("B").ColumnWidth = lMaxSize(1) m_pWorksheet.Columns("C").ColumnWidth = lMaxSize(2) m_pWorksheet.Columns("D").ColumnWidth = lMaxSize(3) m_pWorksheet.Columns("E").ColumnWidth = lMaxSize(4) m_pWorksheet.Columns("F").ColumnWidth = lMaxSize(5) m_pWorksheet.Columns("G").ColumnWidth = lMaxSize(6) m_pWorksheet.Columns("H").ColumnWidth = lMaxSize(7) m_pWorksheet.Columns("I").ColumnWidth = lMaxSize(8) sFileName = "C:200FootList_" & sFirstRecord & ".xls" Call m_pWorksheet.SaveAs(sFileName) 'Save Excel file (for this instance) m_pAppExcel.DisplayAlerts = False Call m_pWorksheet.SaveAs("C:200FootListMerger.xls") 'Save dummy copy of Excel file m_pAppExcel.DisplayAlerts = True ' for mail merge (always overwrites) Call m_pWorkbook.Close Call m_pAppExcel.Application.Quit 'Quit Excel Set m_pAppWord = CreateObject("word.application") 'Create Word instance m_pAppWord.ActivePrinter = "\DellserverSHARP407 on Ne04:"
'Open document for mail merge Set m_pDocument = m_pAppWord.Documents.Open("C:MailMerge.doc")
Call m_pDocument.MailMerge.OpenDataSource("C:200FootListMerger.xls") m_pDocument.MailMerge.Destination = wdSendToNewDocument m_pDocument.MailMerge.Execute
Call m_pDocument.PrintOut 'Print letters Call m_pDocument.Close Call m_pAppWord.Application.Quit(False) 'Quit Word End Sub
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Ms Word 97: Printing In The Background While Word Saves And Closes.
Along with my last post about how to insert text into table in word, I need to find a way to send it to the printer and then close.
Currently I've got a line stating :
Code:
WordDoc.PrintOut
WordDoc.SaveAs ("C: est4.doc")
WordObj.Quit
But this will send it to the printer, save the file and then quit. But when it quits it will send up a query stating that quiting word while it is printing will cancel the print job. Is there a way send the print job to the printer to print in the background and close word, hope this makes sense
When Word Closes
I am writting a addin for Word and what I need to do is when this screen comes up:
http://www.jcouncil.com/menu.gif
This code must run.
Code:
Private Sub wDoc_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean)
On Error Resume Next
If oApp.Documents.Count > 1 Then
Exit Sub
Else
Span_n.Enabled = False
Span_a.Enabled = False
Span_e.Enabled = False
Span_i.Enabled = False
Span_o.Enabled = False
Fren_a.Enabled = False
Fren_e.Enabled = False
Ger_b.Enabled = False
Ger_a.Enabled = False
Ger_o.Enabled = False
Ger_u.Enabled = False
Punc_Mark.Enabled = False
Punc_Point.Enabled = False
End If
End Sub
The only problem I have is when the person clicks 'cancel' I don't want the code to work. How do I program that.
How To Catch When Word Closes
Hi there, i have a vb app that opens a .dot, fill some fields in the document, and saves it with a name specified. During the process, i deactivate menus and some commands of the File menu, this is for security purposes as the end user only should be able to print the document, the problem is that when i open another Word window, it seems that the Normal.dot keeps this configuration, i was figuring out how to do this without affecting Word for future use. Do you know how can this be done? I was thinking on catch when the user closes the Word window that i generate from VB, but i don't know how. this is the code:
Function DoWordInvoice(ByVal InvNum As Variant, ByVal DsnName As Variant, _
ByVal user_id As Variant, ByVal pass As Variant, _
ByVal Plantilla_Seleccionada As Variant, ByVal Path_Dot As Variant, _
ByVal WhereSaveWord As Variant, ByVal DocNameToSave As Variant)
Dim miRst As New ClsGnxQuery
Dim vdsn
Dim vuser_id
Dim vpass
Dim Ors As Recordset
' Variables Word
Dim mWord As Word.Application
Dim arrData()
Dim arrTags()
Dim i, j, iLoop
Dim PathWord
' variables for db conectivity
vdsn = DsnName
vuser_id = user_id
vpass = pass
PathPlantilla = Path_Dot
On Error GoTo Err_Handler
' Call the getInvoiceData function allocated in the ClsGnxQuery to get the data
' to be stored in the Word document
Set Ors = miRst.getInvoiceData(InvNum, vdsn, vuser_id, vpass)
' Se valida si hay datos, de lo contrario, se manda un mensaje
If Not Ors.EOF Then
' Once the data is obtained, proceed to make the Word document
'SaveWord = "C:ProgramacionVB6WordCom Template WordFactura.doc"
SaveWord = WhereSaveWord & DocNameToSave
templateName = Plantilla_Seleccionada
PcvePro = Ors!PdCvePro
PCliNombre = Ors!CliNombre
Phoy = Date
Pdirecc = Ors!CliDir
Pcolonia = Ors!CliColonia
PEdo = Ors!CliEdo
Pdescrip = Ors!UNIDes
Pserie = Ors!RSerie
Pmotor = Ors!RMotor
Piva = Ors!PdIva
Ptot = Ors!PDTotal
Psub = (Ptot - Piva)
' Starts Word
Set mWord = New Word.Application
strTemplateName = templateName
'mWord.ChangeFileOpenDirectory ("C:ProgramacionVB6WordCom Template Word")
mWord.ChangeFileOpenDirectory (PathPlantilla)
mWord.Documents.Open (templateName)
' deactivate word menus
mWord.CommandBars("Standard").Enabled = False
mWord.CommandBars("Formatting").Enabled = False
mWord.CommandBars("Insert").Enabled = False
mWord.CommandBars("Tools").Enabled = False
mWord.CommandBars("Table").Enabled = False
mWord.CommandBars("Format").Enabled = False
mWord.CommandBars("View").Enabled = False
' deactivates File menu commands
mWord.CommandBars("File").Controls(1).Enabled = False
mWord.CommandBars("File").Controls(2).Enabled = False
mWord.CommandBars("File").Controls(3).Enabled = False
mWord.CommandBars("File").Controls(4).Enabled = False
mWord.CommandBars("File").Controls(5).Enabled = False
mWord.CommandBars("File").Controls(6).Enabled = False
mWord.CommandBars("File").Controls(7).Enabled = False
mWord.CommandBars("File").Controls(8).Enabled = False
mWord.CommandBars("File").Controls(9).Enabled = False
mWord.CommandBars("File").Controls(10).Enabled = False
mWord.CommandBars("File").Controls(12).Enabled = False
mWord.CommandBars("File").Controls(13).Enabled = False
'mWord.CommandBars("File").Controls(14).Enabled = False
' Fill the word document
ReDim arrData(11)
ReDim arrTags(11)
arrData(0) = PcvePro
arrTags(0) = "<PcvePro>"
arrData(1) = PCliNombre
arrTags(1) = "<PCliNombre>"
arrData(2) = Phoy
arrTags(2) = "<Phoy>"
arrData(3) = Pdirecc
arrTags(3) = "<Pdirecc>"
arrData(4) = Pcolonia
arrTags(4) = "<Pcolonia>"
arrData(5) = PEdo
arrTags(5) = "<PEdo>"
arrData(6) = Pdescrip
arrTags(6) = "<Pdescrip>"
arrData(7) = Pserie
arrTags(7) = "<Pserie>"
arrData(8) = Pmotor
arrTags(8) = "<Pmotor>"
arrData(9) = Psub
arrTags(9) = "<Psub>"
arrData(10) = Piva
arrTags(10) = "<Piva>"
arrData(11) = Ptot
arrTags(11) = "<Ptot>"
For iLoop = 0 To UBound(arrTags)
mWord.ActiveDocument.Content.Find.Execute arrTags(iLoop), , True, , _
, , , , , arrData(iLoop), 2
Next iLoop
mWord.Visible = True
mWord.ActiveDocument.SaveAs (SaveWord)
Else
MsgBox ("The number given, doesn't exist")
End If
Set mWord = Nothing
Set miRst = Nothing
Exit Function
Err_Handler:
Set miRst = Nothing
Err.Raise Err.Number, Err.Source, Err.Description
End Function
Print Envelopes In Word From Excel
I have a list of names and addresses and I need to be able to loop through them one at a time, printing an envelope from Word for each one. Here's what I have right now but it's not working.
Code:
Sub envelopes()
Dim WordApp As Object
Set WordApp = CreateObject("Word.Application")
Dim lstnm As String
Dim fstnm As String
Dim add As String
Dim city As String
Dim state As String
Dim zip As String
Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.add
ActiveDocument.MailMerge.MainDocumentType = wdEnvelopes
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\SBSNEALUsers
ichardqueenDatabasesJCMS Clients.xls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB .4.0;Password="""";User ID=Admin;Data Source=" _
& "\SBSNEALUsers
ichardqueenDatabasesJCMS Clients.xls;" _
& "Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";" _
& "Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";" _
& "Jet OLEDB:Database Passw" , _
SQLStatement:="SELECT * FROM `Letters$`", _
SQLStatement1:="", SubType:= wdMergeSubTypeAccess
Sheets("Letters").Range("A2").Select
'Do
fstnm = Selection.Offset(0, 1).Value
lstnm = Selection.Value
add = Selection.Offset(0, 2).Value
city = Selection.Offset(0, 3).Value
state = Selection.Offset(0, 4).Value
zip = Selection.Offset(0, 5).Value
ActiveDocument.Envelope.PrintOut ExtractAddress:=False, OmitReturnAddress _
:=True, PrintBarCode:=True, PrintFIMA:=False, Height:=InchesToPoints( _
4.13), Width:=InchesToPoints(9.5), Address:=fstnm & " " & lstnm & Chr(13) & _
add & Chr(13) & city & "," & state & " " & zip, AutoText:="", _
ReturnAddress:="", ReturnAutoText:="", AddressFromLeft:=wdAutoPosition, _
AddressFromTop:=wdAutoPosition, ReturnAddressFromLeft:=wdAutoPosition, _
ReturnAddressFromTop:=wdAutoPosition, DefaultOrientation:= _
wdCenterLandscape, DefaultFaceUp:=True, PrintEPostage:=False
Selection.Offset(1, 0).Activate
'Loop Until Selection.Value = "end"
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
WordDoc.Close SaveChanges:=False
WordApp.Visible = True
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub
How To Capture When Word Or Office App Closes
Hi there, i've seen some messages about this topic but
not so much code available, just some snippets, could
you send some code that showas how to get a value when
Word closes? Let me tell you a little more, in my VB
app i open word and writes some stuff on it, i'm
disabling some word's commands but i need to get when
Word closes to activate those commands again, i guess
this can be done from my vb app already existent. Any
help will be great.
Regards
Word VBA / Macro Problem With Print && Browser (Word 2000)
I am trying to use a macro inside the AutoOpen() event of a Word doc so that when the Word doc is opened inside IE, it will print the Word doc then close both the Word doc and the IE window. For some reason, VBA loses its reference to the doc object and IE Application object after the PrintOut line is executed. I have tried things like:
Sub AutoOpen()
MyWord.Visible = False
MyWord.ActiveDocument.PrintOut
MyWord.ActiveDocument.Close False
End Sub
or:
Sub AutoOpen()
With ActiveDocument
.PrintOut Background:=False
.Close savechanges:=False
.Parent.Quit
End With
End Sub
or:
Sub AutoOpen()
Dim MyWord As Object
Set MyWord = GetObject(, "Word.Application")
Dim IE As Object
Dim IEDoc As Object
Set IE = GetObject(, "InternetExplorer.Application")
Set IEDoc = MyWord.ActiveDocument
IEDoc.PrintOut
IEDoc.Close
IE.Quit
End Sub
But whatever I try, the Word doc prints, then throws a 4605 error about the method or property not being available because the document is in another app. Any ideas?
Thanks,
Chris
How To Print An Embeded Word Document In Excel?
hi
I have an excel file, and in one sheet I have embeded a word document. the word document is 12 pages long... how can I print the hole embeded word document??
I tried adding a print button in the word document and I only wrote
thisDocument.printOut
it gives me this error: This command is Invalid
I tried the same code in a normal word document and works just fine... but I do't know what happens when you insert the word document in an excel sheet...
thanks
Word - Unloading A Moduile When Document Closes
Hello all. I have a collection of macros that, open opening the particular document, create a custom toolbar and button and assign a button.
I am looking for a way to stop or unload that collection when the document closes or another approach that will avoid multiple toolbars being created everytime a similar document is opened.
Maybe I should have a condition in the macro itself that checks for the presence of the toolbar before running itself?
I am a beginner when it comes to VB so any help apprecieated. Thanks, Dave
The code that creates the toolbar:
Sub CreateTickToolbar()
Dim NewTBar As CommandBar
Set NewTBar = CommandBars.Add(Temporary:=True)
With NewTBar
.Name = "Tick"
.Position = msoBarFloating
.Visible = True
End With
End Sub
Sub AddTickControl()
Dim CBar As CommandBar
Dim NewControl As CommandBarControl
Set CBar = CommandBars("Tick")
Set NewControl = CBar.Controls.Add(Type:=msoControlButton)
With NewControl
.FaceId = 1000
.OnAction = "Tickcontrol"
End With
CBar.Visible = True
End Sub
The code that runs the macro upon opening:
Private Sub Document_Open()
Call Report_ReminderBox
Call CreateTickToolbar
Call AddTickControl
End Sub
Extract Each Word From A String And Print One Word Per Line.
I have a textbox that contains a string(can be any number of words).
How do i extract each word from the string and
print one word per line onto the form? e.g.
textbox:
Hi can someone please help me
Print to form:
Hi
can
someone
please
help
me
Thanks
Detecting If Excel And Word Has Finished Their Print Jobs
Hi all,
I have a vb app that prints a list of word and excel documents.
The printing works just fine, but I need to know when Word and Excel has finished the print jobs I sent to them, in order to close the applications(word and excel).
If I use the Application.Quit methode, the users of my app sometimes get the message saying : "Word is currently printing. Quitting Word will cancel all pending print jobs........."
I don't want the users to see this message, but I have not found any other way of making sure that Word and Excel has shut down, than to use the Quit methode.
So, in order for me to use the Application.Quit, I need a way to determine if the print jobs has finished.
All suggestions are very very very welcome.
peet
Make Word Document Active And Print From Excel Macro
I have an excel spreadsheet with multiple hyperlinks to MS Word files. I know how to open the files using the following code:
Code:
ActiveWindow.View = xlNormalView
Range("C14").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
I need to know how to make the Word file the active window and then print it to the default printer in VB. I also need to know how to handle any error or warning messages. ie., when a box pops up to tell me the file should be opened as read only.
Thanks
How To Print Word/Excel File Direct To Printer Without Opening That Fi
Is anyone know how to send a word document or a excel file direct to printer without open the file? Is there any command to do this?
Is just like from the windows explorer we point the mouse pointer to that file and right click and select the print to send to the printer.
I need this command to built in my application so that the userscan select a word document or a excel file by specify the filename and file path and then press a button to directly send to the printer.
Thanks
Merging/Importing Word, Excel, Powerpoint And Visio Files Into A Word Document
Does anyone know how to do this or know of a website that has source code that does this? I can't find anything anywhere.
Each Page/Worksheet/Slide goes on a seperate page. Print formatting is retained (landscape/portrait) and if the imported Page/Worksheet/Slide is larger than the page im merging/importing to, it should auto-resize to fit the page.
Thx.
Opening A Word Document With Word From Excel
i want to have a part of an excel macro where it opens up a word document in word (so it would have to open the application itself) and then be able to do everything that i can do using the word vb editor. is there some easy way to do this?
[Excel && Word] Quit Without Saving A Word .doc From Excel
Hi,
This has got to be one of the simpliest things, but for some reason I can't get.
What I am doing is opening a word doc from excel manipulating it and then closing (unload) it . I was trying to use the following code to close the word doc without saving it, but it doesn't work:
Word.Application.DisplayAlerts = wdAlertsNone
Word.Application.ActiveDocument.Save = False
Word.Application.Quit
If anyone can help me out it would be greatly appreciated. Thank-you.
Daniel.
Word VBA - Data From Excel To Word Doc
Hello,
I am looking for a way to populate a Word template I'm creating with data from an Excel Spreadsheet. I would like to access a certain cell in Excel and have whatever is in that cell gets copied into a field in a Word form. I am limited VBA experience so any guidance would be much appreciated!
Thanks!
Word Automation Compiled On XP Doesn't Work On 98
Hello,
I have created a VB6 app that uses word automation to generated reports. This application was developed at first on a 98 machine. Then my workplace migrated to Win XP and my development went along uninterupted. Now I am testing the application on a laptop with 98 for a demo and only the EXEs compiled before I moved to XP allow me to generate docs. The ones compiled on XP Give this error when attempting to generate: "This Program has performed an illegal operation and will be shut down." When I hit the details button, "App name has caused an invalid page fault in module <unknown>" I close this error and another identical error is displaye, but it lists the module as MSVBVM60.DLL and after closing this error box the application shuts down. Anyone have any ideas why this is happening? And if so could you give me an idea of how I could solve this problem? Thanks.
Smoke Williams
Word -> Visual Basic (Listbox Doesn't Go)
Hallo
I have some module in word and I want to separate it from the document and make a dll.
I try to put the code in visual studio but I have a problem with listbox, when I declare a listbox there are two listbox on the list.
And when I try to compile I have an error on addItem method(Argument not optional).
It seem that there is two object with the same name and it takes the wrong one.
This is my code (wich functions in word):
Function addPLZLabel(labelPlz As ListBox, plz As TextBox, ONRP As TextBox, ort As TextBox)
With labelPlz
.AddItem
.List(labelPlz.ListCount - 1, 0) = plz & " " & ONRP & " " & ort
.List(labelPlz.ListCount - 1, 1) = plz
.List(labelPlz.ListCount - 1, 2) = ONRP
.List(labelPlz.ListCount - 1, 3) = ort
End With
End Function
I want to use the original object (the one is used in word) but I don't know how, with a reference?!? Wich?!?
Thank you for your help.
Adelio
Remove All The Lines Of Text Wich Doesn’t Contain A Word .
Hello .
For my second thread ,I need to remove all the lines of text wich doesn’t contain a word .
Or I want to keep the lines wich contains a definite word and to remove all the other lines
How to do ? Would you be able to give me any ideas ?
Example I want to keep the lines wich contains AABB
1/You can download all the tuts off this page
2/On this page, we got the tuts about the basics of what we should know.
3/first, get your tools....AABB(Just Links)
4/Then info on some tools and how to set them up and use them:
Only this line will stay
3/first, get your tools....AABB(Just Links)
because she contains the occurrence AABB
1/2/4/ this lines will have to be remove
WORD Doc - SaveAs Doesn't Destroy The Original Temp File
Here's what I'm trying to do:
From a datagrid, I have any number of rows (assume more than one)I select a row, then click a button that opens up a Word document that is a report template, and the template is modified according to values I extract from a database. The report comes out as I expectI change the name of the report using a SaveAs with a dynamic string as the file nameI select a different row, then click the button again to generate another report in Word, but then I run into a problem...
The original template still has a temp file open, so on the 2nd attempt to create a report, I get a message that says that the template is already open for edit, and I get the option to either "Notify" or open it as "Read Only."
The end-user I'm writing the app for always has tons of reports to do, so I need to find out how to clean up the original temp file via VB code.
This is a snippet of what I have at this point:
Code:
If irsSites.RecordCount > 0 Then
Screen.MousePointer = vbHourglass
Dim appWord As Word.Application
Set appWord = New Word.Application
Dim WordDoc As Object
Set WordDoc = appWord.Documents.Add("c:Documents and SettingsOwnerMy DocumentsAlltel report blank.doc")
appWord.Visible = True 'False
'Populate appropriate bookmarks in the Word document from the database
'code code code....
'Remove invalid file name characters from site id/site name
Dim lsInvalidFileName As String
Dim lsValidFileName As String
Dim X As Integer
lsInvalidFileName = Trim(txtSiteID.Text) & Trim(txtSiteNm.Text)
For X = 1 To Len(lsInvalidFileName)
If Mid(lsInvalidFileName, X, 1) <> "" And _
Mid(lsInvalidFileName, X, 1) <> "/" And _
Mid(lsInvalidFileName, X, 1) <> ":" And _
Mid(lsInvalidFileName, X, 1) <> "*" And _
Mid(lsInvalidFileName, X, 1) <> "?" And _
Mid(lsInvalidFileName, X, 1) <> Chr(1) And _
Mid(lsInvalidFileName, X, 1) <> "<" And _
Mid(lsInvalidFileName, X, 1) <> ">" And _
Mid(lsInvalidFileName, X, 1) <> "|" _
Then
lsValidFileName = lsValidFileName & Mid(lsInvalidFileName, X, 1)
Else
lsValidFileName = lsValidFileName & "_"
End If
Next X
''''''This is the SaveAs where I would expect that the original temp file would be destroyed, but it isn't. How do I clean it up?
WordDoc.SaveAs ("c:Documents and SettingsOwnerMy DocumentsReports" & lsValidFileName & ".doc")
appWord.Visible = True
Screen.MousePointer = vbDefault
End If
Any ideas?
VBA Styles Statement Hangs Word 97 But Doesn't 2000/2002/2003
I have vba code that hangs in Word 97. However, it works in Word 2000/2002/2003. Furthermore, I used WD97 to record a macro that pretty much is the same. I ran the Macro. It crashed. Must active Task Manager and end the process.
Here is a code snippet. It crashes when it hits the last line:
With ActiveDocument.Styles("~Part#").ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 204
'.SpaceBeforeAuto = False
.SpaceAfter = 0
'.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceDouble
.Alignment = wdAlignParagraphCenter
.WidowControl = True
.KeepWithNext = True
.KeepTogether = False
.PageBreakBefore = True
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
End With
'ActiveDocument.Styles("~Part#").NoSpaceBetweenParagraphsOfSameStyle = _
False
ActiveDocument.Styles("~Part#").ParagraphFormat.TabStops.ClearAll
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = "Part %1"
.TrailingCharacter = wdTrailingNone
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Bold = False
.Italic = False
.StrikeThrough = False
.Subscript = False
.Superscript = False
.Shadow = False
.Outline = False
.Emboss = False
.Engrave = False
.AllCaps = False
.Hidden = False
.Underline = wdUnderlineNone
' .Color = wdUndefined
.size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = False
.Name = "Times New Roman"
End With
.LinkedStyle = "~Part#"
End With
ActiveDocument.Styles("~Part#").LinkToListTemplate ListTemplate:= _
ListGalleries(wdOutlineNumberGallery).ListTemplates(1), ListLevelNumber:= _
1
Again, the above line (ActiveDocument.Styles....) crashes Word 97, but is fine in Word 2002/2003/2000
I've searched forums, MSDN, etc. Nothing.
Anybody got a clue?
Opening Word Document From Excel When The Word Document Is Read Only
I'm trying to open a Word document from Excel and have hit a snag. The file I'm trying to access is Read-only and the code stops when the "This file is read-only..." prompt displays. How do I get past this? Here's the code that I have so far (thanks to some help from this forum):
Code:
Sub OpenAndPrint()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim stPathName As String
stPathName = Range("B4").Hyperlinks(1).Address
If Dir(stPathName) <> "" Then
Set wdApp = New Word.Application
wdApp.Visible = True
wdApp.DisplayAlerts = wdAlertsNone 'Tried to turn off the prompt, but it didn't work.
Set wdDoc = wdApp.Documents.Open(stPathName) 'Code stops here and waits for the user to respond to the prompt.
Set wdDoc = Nothing
Set wdApp = Nothing
Else
MsgBox "The file does not exist!", vbInformation
End If
End Sub
Text Driven Query Doesn't Return Records Where Criteria Is First/Last Word In Record.
I am currently converting an old set of Access queries to a VB6.0 application. I am using DAO 3.51. The query is driven by text entered into one or more textbox(es). It works really well in Access, but I am having a hard time converting the SQL syntax in VB.
Here is the query from Access:
SELECT work.ntaID, work.taskdescription, work.taskdefinition
FROM work
WHERE (((work.taskdescription) Like "*" & [] & "*"));
Here is the query, which partially works (it will return records as long as the search criteria isn't the first or the last word in the taskdescription field):
qry = "SELECT * FROM work WHERE ntaID LIKE 'NTA 1*' AND taskdescription LIKE '* " & Text1.Text & " *';"
Sorry, if this is posted elsewhere.
Print To Word
I looked arround but could't find anything...
I want to be able to print to Word, eather the current frame ot the current record. How do I do this?
is there samples out there...
Vb _ Ms Word Print
hi,
my code is
printer.font.size=14
printer.font.bold=true
printer.print "My company Name"
printer.font.size=10
printer.font.bold=false
printer.print "some text"
..
.
.
.
printer.enddoc
====
now in printer
My Company Name
some text
was printed
all i want is - to store the output in to a word document (no previews pls)
thanks in advance
ackid32
Word Does Not Print
Hello to all,
word2000 and vb6
When I run this in debug mode, I get me letters.
If I run this in RUNTIME mode, I get no letters.
here is where I think it does not work
objWordDocuments.Application.PrintOut
Do anyone have any idea what is going on here.
I spend a week on this but could not figured it out.
thanks a bunch.
Private Sub CmdCustomerLetter_Click()
call InitilizeWord
call CheckedBoxSelected
end sub
Private Sub InitilizeWord()
'CREATE MS WORD APPLICATION OBJECT.
If TypeName(objWordApplication) = "Application" Then
Set objWordApplication = GetObject(, "Word.Application")
Else
Set objWordApplication = CreateObject("Word.Application")
End If
Set objWordDocuments = objWordApplication.Documents
Exit Sub
end sub
Private Sub CheckedBoxSelected()
Dim k As Integer
If Me.LvwCust.ListItems.Count > 1 Then
For k = 1 To Me.LvwCust.ListItems.Count
If Me.LvwCust.ListItems.Item(k).Checked Then
Call GetBkMark(k)
End If
Next k
End If
End Sub
Private Sub GetBkMark(ByVal SelItemIndex As Integer)
'*************************************************************************************************** *****************
Dim strPathName As String
Dim strFileName As String
Dim j As Integer
Dim objTemplate As Word.Document
Dim k As Integer
strPathName = App.Path & ""
strFileName = "Customer.dot"
Set objWordDocuments = objWordApplication.Documents
'Set objTemplate = objWordDocuments.Add(strPathName & strFileName, True, wdNewBlankDocument, True)
For k = 1 To Me.LvwCust.ListItems.Count
If k = SelItemIndex Then
Set objTemplate = objWordDocuments.Add(strPathName & strFileName, True, wdNewBlankDocument, True)
With objTemplate
If .Bookmarks.Exists("CustName") Then
.Bookmarks("CustName").Range.text =Trim(Me.LvwCust.ListItems.Item(k).SubItems(2)) & " " & Trim(Me.LvwCust.ListItems.Item(k).SubItems(1)))
End If
'ADDRESS
If .Bookmarks.Exists("Address") Then
.Bookmarks("Address").Range.text = Trim(Me.LvwCust.ListItems.Item(k).SubItems(5)))
End If
objWordDocuments.Application.PrintOut
End With
End If
Next k
End Sub
Print Word Doc...
I am using the following Sub to print a word document, but there are problems with it. I think the issue is the wordDoc.Close or Word.Quit lines. If I set the Word.Visible property to true, I get a 'Do you wish to close without finishing printing?' warning at one of these points, (I haven't bothered to check which), but I'd rather Word is not Visible, and so I need a way to make sure Word has sent the print job before executing these lines...
How can I do that?
Code:
Public Sub PrintWordDocument(FileName As String)
On Error GoTo WordError
Dim Word As Word.Application 'Opens word
Dim wordDoc As Word.Document 'creates document
frmInfo.Show
frmInfo.SetLabel ("Printing Word Document." & Chr(13) & "Please Wait...")
frmInfo.ZOrder 0
Set Word = CreateObject("Word.Application")
Set wordDoc = Word.Documents.Open(FileName)
Word.Visible = True 'False
wordDoc.PrintOut 'Prints Word Document
wordDoc.Close (wdDoNotSaveChanges) 'Close word without saving
Word.Quit
frmInfo.CloseWindow
Exit Sub
WordError:
frmInfo.CloseWindow
warning = MsgBox(Error, vbOKOnly, "Error!")
Set Word = Nothing
Set wordDoc = Nothing
End Sub
Print In Word
Hi!
I'm printing datas from vb with Word and I don't want the user to see anything.
When the user press the print button,
Word opens and set all the values correctly. Word is not visible.
Then I ask to print the document and to close Word.
The problem is that some printers don't have the time to spool the document before Word closes....
So it doesn't print....
If I cancel the Word close, it prints well.
So I need to make Word active until the document is spooled. And then close....
Any ideas????
tks!
Can You Print A Word Doc From A Web App?
I am trying to print a word doc (over our intranet) using vb.net and office 2000, and am having no luck. Is this not possible, or am I doing it wrong.
When I attempt to execute this code I get the following error message: Server execution failed. I have included reference to the Word Library in my project. I have changed my path from the actual path to the virtual path and everything else I could think of to no avail.
Here is the code:
Code:Imports Word
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Public Class frmConfirm
Inherits System.Web.UI.Page
PrintDoc = "\bblweb
taspHirePacketHPDocs 1.doc"
Dim w As Word.Application
Dim d As Word.Document
w = New Word.Application
d = w.Documents.Open(PrintDoc)
d.PrintOut(False)
d.Close()
w.Quit()
w = Nothing
End Sub
I have never posted a question on a site before and if I have done so incorrectly please tell me the correct way to do it.
and thanks,
Won't Print File {Word}
Hey,
I wrote the following code for printing a file:
Code:
Dim objDoc As Word.Document
Option Explicit
Dim afdrukken As Word.Application
... (the following part belongs to a button in a toolbar!)
Case 7
Printer.Font.Name = "arial"
Set afdrukken = New Word.Application
afdrukken.Visible = True
Set objDoc = afdrukken.Documents.Open(App.Path & "" & "KBC.doc")
Select Case fraafpunting.Caption
Case "Overzicht afpunting"
If optopen.Value = True Then
Selection.GoTo wdGoToBookmark, , , "Overzicht"
Selection.TypeText Text:=" afpunting openstaande boekingen per agent"
Selection.GoTo wdGoToBookmark, , , "BVVO:"
Selection.TypeText Text:=lstBVVO.Text
Selection.GoTo wdGoToBookmark, , , "Agent:"
Selection.TypeText Text:=lstagent.Text
Selection.GoTo wdGoToBookmark, , , "Maand:"
Selection.TypeText Text:="niet van toepassing"
Selection.GoTo wdGoToBookmark, , , "Winst/verlies:"
Selection.TypeText Text:="niet van toepassing"
Selection.GoTo wdGoToBookmark, , , "Tabel:"
Selection.TypeText Text:=datagridoverzicht
'datagrid afdrukken
ElseIf optwv.Value = True Then
Selection.GoTo wdGoToBookmark, , , "Overzicht"
Selection.TypeText Text:=" winst/verlies per agent"
Selection.GoTo wdGoToBookmark, , , "BVVO:"
Selection.TypeText Text:=lstBVVO.Text
Selection.GoTo wdGoToBookmark, , , "Agent:"
Selection.TypeText Text:=lstagent.Text
Selection.GoTo wdGoToBookmark, , , "Maand:"
Selection.TypeText Text:="niet van toepassing"
Selection.GoTo wdGoToBookmark, , , "Winst/verlies:"
Selection.TypeText Text:=txtwv.Text
Selection.GoTo wdGoToBookmark, , , "Tabel:"
Selection.TypeText Text:="niet van toepassing"
End If
Case "Overzicht winst/verlies van de afgesloten periodes"
If optpermed.Value = True Then
Selection.GoTo wdGoToBookmark, , , "Overzicht"
Selection.TypeText Text:=" winst/verlies van de afgesloten periode per BVVO"
Selection.GoTo wdGoToBookmark, , , "BVVO:"
Selection.TypeText Text:=lstBVVO.Text
Selection.GoTo wdGoToBookmark, , , "Agent:"
Selection.TypeText Text:=lstagent.Text
Selection.GoTo wdGoToBookmark, , , "Maand:"
Selection.TypeText Text:=lstmaand.Text
Selection.GoTo wdGoToBookmark, , , "Winst/verlies:"
Selection.TypeText Text:=txtwv.Text
Selection.GoTo wdGoToBookmark, , , "Tabel:"
Selection.TypeText Text:=" niet van toepassing"
ElseIf opttotaal.Value = True Then
Selection.GoTo wdGoToBookmark, , , "Overzicht"
Selection.TypeText Text:=" winst/verlies van de afgesloten periode over alle BVVO's heen"
Selection.GoTo wdGoToBookmark, , , "BVVO:"
Selection.TypeText Text:="alle BVVO's samen"
Selection.GoTo wdGoToBookmark, , , "Agent:"
Selection.TypeText Text:="niet van toepassing"
Selection.GoTo wdGoToBookmark, , , "Maand:"
Selection.TypeText Text:=lstmaand.Text
Selection.GoTo wdGoToBookmark, , , "Winst/verlies:"
Selection.TypeText Text:=txtwv.Text
Selection.GoTo wdGoToBookmark, , , "Tabel:"
Selection.TypeText Text:=" niet van toepassing"
End If
Case "Overzicht winst/verlies van het huidig boekjaar"
If optpermed.Value = True Then
Selection.GoTo wdGoToBookmark, , , "Overzicht"
Selection.TypeText Text:=" winst/verlies van het huidig boekjaar per BVVO tot op heden"
Selection.GoTo wdGoToBookmark, , , "BVVO:"
Selection.TypeText Text:=lstBVVO.Text
Selection.GoTo wdGoToBookmark, , , "Agent:"
Selection.TypeText Text:="niet van toepassing"
Selection.GoTo wdGoToBookmark, , , "Maand:"
Selection.TypeText Text:="begin van het boekjaar tot op heden"
Selection.GoTo wdGoToBookmark, , , "Winst/verlies:"
Selection.TypeText Text:=txtwv.Text
Selection.GoTo wdGoToBookmark, , , "Tabel:"
Selection.TypeText Text:=" niet van toepassing"
ElseIf opttotaal.Value = True Then
Selection.GoTo wdGoToBookmark, , , "Overzicht"
Selection.TypeText Text:=" winst/verlies over alle BVVO's heen tot op heden"
Selection.GoTo wdGoToBookmark, , , "BVVO:"
Selection.TypeText Text:="alle BVVO's samen"
Selection.GoTo wdGoToBookmark, , , "Agent:"
Selection.TypeText Text:="niet van toepassing"
Selection.GoTo wdGoToBookmark, , , "Maand:"
Selection.TypeText Text:="begin van het boekjaar tot op heden"
Selection.GoTo wdGoToBookmark, , , "Winst/verlies:"
Selection.TypeText Text:=txtwv.Text
Selection.GoTo wdGoToBookmark, , , "Tabel:"
Selection.TypeText Text:=" niet van toepassing"
End If
End Select
afdrukken.PrintOut
When I click on the print button, it opens the file, but it doesn't fill in the spaces and it doesn't print the file! What is the problem?
Word XP Label Print From VB6?
Hi I need a little help.
I have built an inventory managment system at work and need to be able to print out the labels to put on each piece of inventory. Will need to be able to query the database by a purchase order (done) take the resulting Serial Number and Stock item and put them on a label in Arial Font as well as have the same text next to them in Barcode font. The labels I am using already have a Avery/Word template number assigned, but I don't know how to call the document to start with the template and fill in that information dynamically. Each label will be different information, as looped through the dynaset from our Oracle database.
I will also need the ability to print out single labels as reprints on partial sheets, so I need to give the information to print as well as the row column to print to so as not waste a full sheet of labels.
The way I am currently doing it is to creat a blank table with certain cell padding and font size then manually print some samples and try and make them match up, but having problems with the single label print.
I think there must be an easier way to do this using the word templates, also allowing me to dynamically change them in case we decide to go with different labels or sized labels in the future.
Any help would be appreciated.
Thanks!
How To Print Lables From Word
hello all
let me start off by saying i have never tried to access word from vb there for i have no code to show for this question.
i have a program that runs the national dnc list against a database to see if the numbers are able to be dialed or not now the school that i wrote uit for wants the ability to click a button and print mailing lables for the ones that can not be called, i have all of the code writen to pull the records and i know that word can print labels ,expecially every template 8160. but i have no idea as to how to tell word to do it, i have office xp and vb6. i have searched forum and i see things like
dim wrd as word.document
wrd = new word.something or other
i do not have word as an option but i have word
i also read i would have to use mailmerge again i am stupit
just need a thrust in the right direction
thanks in advance
edit
ok after reading tutorials i have found that i have to reference it to show things after "."
edit
ok i can now open word document and place textr in it but how do i use the avery lables and merge in the data
still can not get to work
Print 1 To Many In A Word Document
Is is possible to create a mail merge through Acces 97 that will merge a main document trailed by a 1 to many list, similar to a main form/subform relationship?.....or would bookmarking be a better option?
Any help appreciated.
Thanks
Netbari
Print And Format Through Word. HELP??
I have a visual Basic application that is connected to a Microsoft Database. It saves records for patients. I want to be able to print a persons info in a certain format I create. Can someone help me figure this out. I am new to printing info from VB and am having a hard time. Should I use Microsoft Word and merge it there or a different way.
Thanks Nick
Dim Range As Word.Range
Dim Myw As Object
'if Word isnt open VB will raise an error, we dont need that
On Error Resume Next
'check if Word is open
Set Myw = GetObject(, "Word.application")
'if Word is not open
If Myw Is Nothing Then
Set Myw = GetObject("", "Word.Application")
Myw.Visible = True
End If
Do Not Print Buttons In Word
Does anyone know how not to have a VBA button print but still show in a word document. I have a button that shows up when certain criteria is met, and allows the user to do something else, but I do not want it to show on the final print.
I can do it in excel, but the property is not in the same place in Word (I am running XP).
I also really want to avoid custom menu's/toolbars for distribution nightmare reasons.
Thanks,
Can't Print And Close Word Right After
In Microsoft word I created a document using VB then I use the following code to print it out and try to close it. however when I try to close it, it says quitting word will cancel the print or something like that.
Here is my code that ends it:
objWord.PrintOut
objWord.ActiveDocument.Close (0)
objWord.Quit
Set objWord = Nothing
Whats wrong with this?
How Do I Print A Word.doc From My VB6 Project?
Hello
I am working on an application that creates a word.doc from information entered into text box's, and once it is saved, I then want to print this word.doc , from within my application. So one button does all "Save & Print"
I have got the doc to save, but do not know how to open this saved doc and print it!
Any help would be great!
How Does MS Word Print To File?
Try this one guys and gals:
Type a few words in MS Word then click print. Choose the print to file checkbox and then click print. Up comes a nifty little dialog box that let's you choose directories, etc.
Now try the same thing with Wordpad. You get a single textbox that doesn't include default file name, directories, etc.
I can get my program to print to file a la Wordpad, but I'd much rather it print to file like MS Word.
Any help?
PS, I've already got a form that lets you navigate directories, choose a file name and so forth. I just need a way to actually print to the file that I choose with the form.
Thanks in advance.
Print Word Document Using VBA
If anyone could help me out with this i'd be grateful.
Scenario---
I wish to automatically print out a word document when forced by me using VBA code. I have used the commondialog.showprinter statement to bring up the common dialog printer window (as required) yet when I click print the document is not printed. It just returns me to the code. How do I get this to print. Any ideas. Have I missed out initialising some value somwhere? Is there another way to print from within the VBA section for word (I NEED TO PROVIDE A LIST OF PRINTERS TO CHOOSE FROM - THAT IS WHY I AM USING THE COMMON DIALOG!!!"
VB6 Word Print [*Resolved*]
I am opening up a word document from a template using VB6.
Is there any way of the VB6 application knowing if the user has printed the document from word?
Thanks
Kev.
"I love deadlines. I like the whooshing sound they make as they fly by. " - Douglas Adams
MS Word Print Error
i have a vb app that prints records from a DB to ms word. i used bookmarks and just selected the bookmarks in the code and dumped the data in the word template based on the bookmark. this all worked fine until i put some code in for a check box. all the other bookmarks work but when i stepped through the code it said that- "The requested member of the collection does not exist". iahve another program that i used the same code to put check boxes into a word document and print and it worked. any one know why it is saying that the book mark isn't there when i know it is?
How To Print Word Documents?
Hello all,
Im having problems printing from vb. I want to envoke a word template ("irsquote.doc") and swap some values on the template for my variables and print it out.
here is my code:
Private Sub Command3_Click()
Dim WordDoc As New Word.Application
' Open Word with your template
WordDoc.Documents.Add ("irsquote.doc")
With WordDoc.ActiveDocument
.FormFields(yourfield1).Result = "New quote Number"
.FormFields.Locked = True
.PrintOut
End With
WordDoc.Quit
End Sub
however, my application fails on the first line (dim WordDoc as new word.Application)
It says user defined type not defined
Any ideas?
Oh, and will the code work?
Print An MS Word Document
Hi
Is there a way in VB6 to print a MS Word document using a specified printer driver (not the default one)?
Thanks!
Print Preview Of A Word Doc...
Is there a way of preview a word document, that I just made via code, without opening word?
I do not want to open up word, but do want to allow the user to view a snapshot, of sorts, of the doc they just compiled...
Bob
|