Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2005

Tip: Looking for answers? Try searching our database.

Autorun macro to fix Tools-Options->view with imported worksheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lyndon Rickards - 25 Dec 2005 02:22 GMT
Greetings,

Have scanned the archive and google so now I come to the Oracles...

Problem:
Multi-worksheet excel file created with perl script. This is a report
with graphics, buttons and hyperlinks probably best done in
html. Don't ask why. Now I need to 'clean up' the appearance by removing
Row&Column headers etc. as available under Tools->Options->View, in each
worksheet.

Proposed:
After the spreadsheet is created, I add a cover page from a template
spreadsheet. I'm thinking it may be possible to copy in a macro
at the same time (from the template) to set the appearance of the
destination workbook. Maybe the macro could even autorun 'run-once' on
the import and delete itself..?

Is this practical? Any pointers, references, examples please?

Bear in mind my native planet is in the galaxy of *nix ;-)

TIA - Lynn.
Dave Peterson - 25 Dec 2005 13:41 GMT
Etc is a lot to do (or not).

But this shell may give you an idea of what to do.  It displays a file|open
dialog.  The user can select as many files as they want and then the template
workbook will be added to each workbook--and just the row/column headings are
hidden.

Option Explicit
Sub testme01()

   Dim wksTemplateName As String
   Dim myFileNames As Variant
   Dim wkbk As Workbook
   Dim wks As Worksheet
   Dim fCtr As Long
   Dim myWindow As Window
   
   wksTemplateName = "C:\my documents\excel\book1.xls"

   myFileNames = Application.GetOpenFilename("Excel Files, *.xls", _
                     MultiSelect:=True)
   
   If IsArray(myFileNames) = False Then
       Exit Sub
   End If
       
   For fCtr = LBound(myFileNames) To UBound(myFileNames)
       Set wkbk = Workbooks.Open(Filename:=myFileNames(fCtr))
       Sheets.Add before:=wkbk.Sheets(1), Type:=wksTemplateName
       For Each wks In wkbk.Worksheets
           wks.Activate
           ActiveWindow.DisplayHeadings = False
           'anything else you need here
       Next wks
       Application.Goto wkbk.Worksheets(1).Range("a1"), scroll:=True
       wkbk.Save
       wkbk.Close savechanges:=False
   Next fCtr

End Sub

> Greetings,
>
[quoted text clipped - 19 lines]
>
> TIA - Lynn.

Signature

Dave Peterson

Lyndon Rickards - 25 Dec 2005 15:18 GMT
Thanks Dave - and on Xmas morning, too! Guess this'll be what I'll
be playing with later...

 - Lynn.

> Etc is a lot to do (or not).
>
[quoted text clipped - 5 lines]
> Option Explicit
> Sub testme01()

<---------snip

>>Bear in mind my native planet is in the galaxy of *nix ;-)
>>
>>TIA - Lynn.
Dave Peterson - 25 Dec 2005 16:27 GMT
Good luck...

You may want to record a macro while you're turning things on/off to get the
code to merge into that shell.

> Thanks Dave - and on Xmas morning, too! Guess this'll be what I'll
> be playing with later...
[quoted text clipped - 16 lines]
> >>
> >>TIA - Lynn.

Signature

Dave Peterson

Dave Peterson - 25 Dec 2005 13:41 GMT
ps...

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

> Greetings,
>
[quoted text clipped - 19 lines]
>
> TIA - Lynn.

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.