+ Reply to Thread
Results 1 to 2 of 2

Writing to Closed Excel File

Hybrid View

yawnzzzz Writing to Closed Excel File 08-26-2010, 03:30 PM
JBeaucaire Re: Writing to Closed Excel... 08-26-2010, 08:19 PM
  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387

    Writing to Closed Excel File

    What's the best (quickest) way to write to a closed Excel file?

    Right now, I'm opening the file and writing to it, but is there a faster way? I don't need to 'read' from the file for any reason.

    sCopyName = ThisWorkbook.Path & "\Pricing Tool.xls"
                Set Wkb = Workbooks.Open(sCopyName, UpdateLinks:=0)
                Workbooks("Pricing Tool").Sheets("Manufacturer Codes").Cells(finalProduct, manCodeCol) = codeTextbox.Value
                Workbooks("Pricing Tool").Sheets("Manufacturer Codes").Cells(finalProduct, manNameCol) = manufacturerTextbox.Value
                Workbooks("Pricing Tool").Sheets("Manufacturer Codes").Cells(finalProduct, manDescCol) = descriptionTextbox.Value
                Workbooks("Pricing Tool").Sheets("Manufacturer Codes").Cells(finalProduct, manPriceCol) = priceTextbox.Value
                Workbooks("Pricing Tool").Sheets("Manufacturer Codes").Cells(finalProduct, manInstallCol) = installTextbox.Value
                Workbooks("Pricing Tool").Sheets("Manufacturer Codes").Cells(finalProduct, manSearchCol) = searchTextbox.Value
                If Val(Application.Version) < 12 Then
                    'You use Excel 97-2003
                    Workbooks("Pricing Tool").SaveAs Filename:=sCopyName
                Else
                    'You use Excel 2007
                    Workbooks("Pricing Tool").SaveAs Filename:=sCopyName, FileFormat:=56
                End If
                Wkb.Close False

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Writing to Closed Excel File

    You can't really write to a closed file, so what you're doing is fine.

    Does it "feel" slow to you? If so, use the Application.ScreenUpating = False at the top and = True at the end, see if that helps.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1