Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I doubt whether the below will run on someone elses machine as you may
need to play arounfd with the variables (the "blah blah" bits definitely won't work!) Is the below sound code in terms of getting things to run quickly?....because things don't seem to run very quickly when it executes. (I have a feeling it has something to do with the public variable WordApplication?!) Any help greatly appreciated Jason Q Public WordApplication As Object Sub AppOpen() Dim strApp As String strApp = "Word.Application" 'check to see if Word is running On Error Resume Next If Not IsRunning(strApp) Then Set WordApplication = CreateObject(strApp) Else Set WordApplication = GetObject(, strApp) End If On Error GoTo 0 strApp = "" myFilePath = "I: blah blah " & strFile & ".Doc" myFileCopy = "I: blah blah " & strFile & "\" & strFile & " " _ & Now & ".Doc" FileSystem.FileCopy myFilePath, myFileCopy 'USING A REFERENCE With WordApplication .WindowState = 2 .Visible = True End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Seems to me the slowest part of this will be the file copy: any disk access
time will be much slower than the execution of your code. To improve the way you are accessing Word through code, it is better to explicitly define your variable to be a Word application instead of a generic object (see below); you could try changing this and see if it improves speed but I still think that the time to execute the file copy will by far outweigh any improvement you can make in your code execution time: Public WordApplication as Word.Application Sub AppOpen() Dim strApp As String strApp = "Word.Application" 'check to see if Word is running On Error Resume Next If Not IsRunning(strApp) Then Set WordApplication = New Word.Application Else Set WordApplication = GetObject(, strApp) End If On Error GoTo 0 .... "jase" wrote: I doubt whether the below will run on someone elses machine as you may need to play arounfd with the variables (the "blah blah" bits definitely won't work!) Is the below sound code in terms of getting things to run quickly?....because things don't seem to run very quickly when it executes. (I have a feeling it has something to do with the public variable WordApplication?!) Any help greatly appreciated Jason Q Public WordApplication As Object Sub AppOpen() Dim strApp As String strApp = "Word.Application" 'check to see if Word is running On Error Resume Next If Not IsRunning(strApp) Then Set WordApplication = CreateObject(strApp) Else Set WordApplication = GetObject(, strApp) End If On Error GoTo 0 strApp = "" myFilePath = "I: blah blah " & strFile & ".Doc" myFileCopy = "I: blah blah " & strFile & "\" & strFile & " " _ & Now & ".Doc" FileSystem.FileCopy myFilePath, myFileCopy 'USING A REFERENCE With WordApplication .WindowState = 2 .Visible = True End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
SLOW Code... | Excel Programming | |||
Late Binding examples of binding excel application | Excel Programming | |||
Slow Code | Excel Programming | |||
Is this slow code? | Excel Programming | |||
EARLY binding or LATE binding ? | Excel Programming |