Mark A Matte
markamatte at hotmail.com
Thu Jul 26 15:18:14 CDT 2007
I'm not sure exactly what you are asking...but #2 sounds like you want to do some formatting? If so...below is some code I use to format a spreadsheet (from within Access), that is actually created from an exported Access report. If I missed the point...sorry, let me know and I'll try again. Good Luck, Mark A. Matte P.S...the formatting is based on a recordset within the db. With appExcel .Workbooks.Open strpathTemp1, 0 '.Visible = True 'just to watch the sheet .ActiveSheet.Name = strReport .Range("A1:AC1").Select .Selection.Font.Bold = True .Selection.Font.Name = "Arial" .Selection.Font.Size = 12 Do Until MyRst.NoMatch Counter = Counter + 1 .Cells(1, Counter) = MyRst!Reas_cd If MyRst![View] = 0 Then .Cells(1, Counter).Font.Color = 255 MyRst.FindNext strSQL Loop .Columns.AutoFit .Rows.AutoFit .Columns.Borders.Color = vbBlack .ActiveWorkbook.Save End With appExcel.Quit >From: ewaldt at gdls.com >Reply-To: Access Developers discussion and problem >solving<accessd at databaseadvisors.com> >To: accessd at databaseadvisors.com >Subject: Re: [AccessD] Importing from Excel >Date: Thu, 26 Jul 2007 15:34:51 -0400 > >I wrote the code below, which works really well and I'm very happy with >it. This is code for Excel, though. What I need to do is the following: > >1. Have the user find the Excel file (I can do this). >2. Have the code below apply to the Excel file (Don't know how to do this >from within Access). >3. Have Access run the import process on the new worksheet (Not sure how >to have it do that specific sheet; can it work on a workbook already in >memory without saving the Excel file first?). >4. Do more processing of the data (I have this set up). > >So I really need help with #2 and maybe #3 above. Of course #2 is using >the Excel object model, and that has to be taken into consideration. > >Any help? Thanks. > >Thomas F. Ewald >Stryker Mass Properties >General Dynamics Land Systems > >---------------------------------------------------------- >Sub PrepForImport() > >' Created 7/26/2007 by ewaldt > >Dim intLastRow As Integer >Dim intCount As Integer >Dim intNewRow As Integer >Dim oCell As Object > > Sheets.Add > Sheets("Sheet1").Name = "ToImport" > Sheets("ToImport").Select > >'Copy only rows where column B = "A" > intNewRow = 1 > > For Each oCell In Sheets("GDLS-SHC").Range("B:B") > If oCell.Formula = "A" Then > oCell.EntireRow.Copy > ActiveSheet.Paste >Destination:=Worksheets("ToImport").Range("A" & intNewRow) > intNewRow = intNewRow + 1 > End If > Next oCell > > For Each oCell In Sheets("GDLS-C").Range("B:B") > If oCell.Formula = "A" Then > oCell.EntireRow.Copy > ActiveSheet.Paste >Destination:=Worksheets("ToImport").Range("A" & intNewRow) > intNewRow = intNewRow + 1 > End If > Next oCell > >'Check for non-numeric in Pounds and Grams > For Each oCell In Sheets("ToImport").Range("C1:D" & intNewRow - 1) > If Not IsNumeric(oCell.Formula) Then > oCell.Formula = 0 > End If > Next oCell > >End Sub > > > >This is an e-mail from General Dynamics Land Systems. It is for the >intended recipient only and may contain confidential and privileged >information. No one else may read, print, store, copy, forward or act in >reliance on it or its attachments. If you are not the intended recipient, >please return this message to the sender and delete the message and any >attachments from your computer. Your cooperation is appreciated. > >-- >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com _________________________________________________________________ Local listings, incredible imagery, and driving directions - all in one place! http://maps.live.com/?wip=69&FORM=MGAC01