Fields(i - 1).Name
Next i
TheWorksheet.Cells(2, 1).CopyFromRecordset rs
TheWorksheet.Select
xl.Selection.CurrentRegion.Select
xl.Selection.Columns.AutoFit
rs.Close
Set TheWorksheet = Nothing
Set rs = Nothing
Set xl = Nothing
End Sub
nNote Once again, the VB 6 code provided here is for reference only, showing the similarities to code
we??™ve already experienced.We will not dig into the specifics of compiling DLLs or ActiveX EXEs here.
As you??™ll see in this next bit of client code, accessing the data from an external component
really helps keep the code on the client application simple. The compiled version of this code
is available at www.apress.com in the Download section of this book??™s home page. It is called
Nwind2Excel.dll. You must register the DLL before you can access its functionality.
CHAPTER 9 n ACTIVEX AND .NET 319
Registering Nwind2Excel.dll in Windows XP or 2000
1. Copy the file to a folder on your local machine.
2. Click Start ?¤ Run.
3. Type regsvr32.exe, followed by a space, and then the full path to Nwind2Excel.dll.
Listing 9-4 shows an example of this command.
Listing 9-4. Example of Run Command to Register a DLL
regsvr32.exe C:\MyComponents\Nwind2Excel.dll
4. Click OK to register the DLL.
5. Click OK when the success message appears.
nCaution In the VB code, be sure to change the path to the Northwind 2007 database to wherever it can
be found on your local machine. If you are using the compiled DLL, it needs to find the Northwind database
in C:\ExampleDBs.
Pages:
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298