Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro in excel which utilises Word using late binding.
Generally its ok but, especially if the user already has Word running on their machine.If it is the morning and they don't have word running then when they run the macro the required sheet will appear but in a Word Document which has NO toolbars - therefore its a bit tricky printing the document!! Here's, pretty much, the code I'm using: strApplication = "Word.Application" 'check to see if Word is running If Not IsRunning(strApplication) Then Set WordApplication = CreateObject(strApplication) Else Set WordApplication = GetObject(, strApplication) End If strApplication = "" myFilePath = "I:\Fin\" & strFile & ".Doc" myFileCopy = "I:\Fin\" & strFile & "\" & strFile & " " & Format(Now, "dd mmm _ yyyy hh-mm-ss AMPM") & ".Doc" FileSystem.FileCopy myFilePath, myFileCopy Call CreateVariables 'creates all the following variables starting with "my" With WordApplication 'put in the data into the word document With .documents.Open(Filename:=myFileCopy) .Range.Bookmarks("Policy_Number").Range.InsertAfte r myPNumber .Range.Bookmarks("The_Date").Range.InsertAfter myDate .Range.Bookmarks("Fund_Description").Range.InsertA fter _ myDescription End With .ACTIVEDOCUMENT.Save .WindowState = wdWindowStateMinimize End With Call DestroyVariables 'destroys all variables starting with "my" ThisWorkbook.Activate WordApplication.Visible = True Set WordApplication = Nothing ANY HELP ON THIS LITTLE TEASER IS GREATLY APPRECIATED Jason |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
add delta symbol to toolbars in word and excel | Excel Discussion (Misc queries) | |||
the toolbars in Word has gone missing. even after reinstalling | Excel Discussion (Misc queries) | |||
Creating/Destroying Toolbars Programmatically | Excel Programming | |||
Does destroying the ADO Connection close the database? | Excel Programming |