Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #108195

Re: Can this code be optimized?

From Claus Busch <claus_busch@t-online.de>
Newsgroups microsoft.public.excel.programming
Subject Re: Can this code be optimized?
Date 2015-11-25 21:12 +0100
Organization A noiseless patient Spider
Message-ID <n354ip$8tc$1@dont-email.me> (permalink)
References <VPSdnVPvTbBQBsjLnZ2dnUVZ5rqdnZ2d@giganews.com> <n34k6a$tts$2@dont-email.me> <-aOdnckyPcfGn8vLnZ2dnUVZ5s6dnZ2d@giganews.com> <n35007$tts$6@dont-email.me> <hO-dnTSRZZblk8vLnZ2dnUVZ5qWdnZ2d@giganews.com>

Show all headers | View raw


Hi Robert,

Am Wed, 25 Nov 2015 12:39:35 -0700 schrieb Robert Crandal:

> I remember that ADO was another option for editing
> Excel files without opening the file in Excel, so I might
> try that.

open workbook "main", write a 1 in sheet1 range("A1"), copy that
workbook and save it with the new name, delete the 1 in "main" and close
and save:

Sub Test()
Dim FSO As Object
Dim j As Long

Set FSO = CreateObject("Scripting.FileSystemObject")
Workbooks.Open "C:\main.xlsm"
With ActiveWorkbook
    Sheets(1).Range("A1") = 1
    .Save
End With

For j = 1 To 5
    FSO.CopyFile _
        "C:\main.xlsm", "C:\version" & j & ".xlsm"
Next
With ActiveWorkbook
    Sheets(1).Range("A1").ClearContents
    .Close savechanges:=True
End With
End Sub


Regards
Claus B.
-- 
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

Back to microsoft.public.excel.programming | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Can this code be optimized? "Robert Crandal" <noreply2me@yahoo.com> - 2015-11-25 04:30 -0700
  Re: Can this code be optimized? Claus Busch <claus_busch@t-online.de> - 2015-11-25 14:09 +0100
  Re: Can this code be optimized? witek <witek7205@gazeta.pl.invalid> - 2015-11-25 09:32 -0600
    Re: Can this code be optimized? "Robert Crandal" <noreply2me@yahoo.com> - 2015-11-25 11:47 -0700
      Re: Can this code be optimized? witek <witek7205@gazeta.pl.invalid> - 2015-11-25 12:54 -0600
        Re: Can this code be optimized? "Robert Crandal" <noreply2me@yahoo.com> - 2015-11-25 12:39 -0700
          Re: Can this code be optimized? Claus Busch <claus_busch@t-online.de> - 2015-11-25 21:12 +0100
            Re: Can this code be optimized? "Robert Crandal" <noreply2me@yahoo.com> - 2015-11-25 16:15 -0700
              Re: Can this code be optimized? GS <gs@v.invalid> - 2015-11-25 19:46 -0500
                Re: Can this code be optimized? "Robert Crandal" <noreply2me@yahoo.com> - 2015-11-25 18:51 -0700
                Re: Can this code be optimized? GS <gs@v.invalid> - 2015-11-25 22:07 -0500
                Re: Can this code be optimized? "Robert Crandal" <noreply2me@yahoo.com> - 2015-12-11 03:59 -0700
                Re: Can this code be optimized? Claus Busch <claus_busch@t-online.de> - 2015-11-26 09:48 +0100

csiph-web