Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

List of all worksheet format properties...

Posted on 2004-08-21
12
Medium Priority
?
350 Views
Last Modified: 2008-03-06
How can I create a list of all properties a worksheet may have:

Left Margin, right margin, top magin, bottom margin
font size, font style, font color, font underscore, font strike through,
zoom, left page header, right page header, center page header, etc....

0
Comment
Question by:Mike Eghtebas
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 22

Assisted Solution

by:DarkoLord
DarkoLord earned 800 total points
ID: 11863197
Hi, use this:

Dim objExcel As Excel.Application
    Dim objWrkSht As Worksheet
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Workbooks.Add
    Set objWrkSht = objExcel.ActiveWorkbook.Sheets(1)


With objWrkSht.PageSetup
Debug.Print .LeftHeader
Debug.Print .CenterHeader
Debug.Print .RightHeader
Debug.Print .LeftFooter
Debug.Print .CenterFooter
Debug.Print .RightFooter
Debug.Print .LeftMargin
Debug.Print .RightMargin
Debug.Print .TopMargin
Debug.Print .BottomMargin
Debug.Print .HeaderMargin
Debug.Print .FooterMargin
Debug.Print .PrintHeadings
Debug.Print .PrintGridlines
Debug.Print .PrintComments
'Debug.Print .PrintQuality
'Debug.Print .PrintArea
Debug.Print .CenterHorizontally
Debug.Print .CenterVertically
Debug.Print .Orientation
Debug.Print .Draft
Debug.Print .PaperSize
Debug.Print .FirstPageNumber
Debug.Print .Order
Debug.Print .BlackAndWhite
Debug.Print .Zoom
End With
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11863200
Oops forgot the unloading code... append this to the end:

   Set objWrkSht = Nothing
   Set objExcel = Nothing


Darko
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11863734
Thank you for the code.  Actually I was looking for a list to identify all properies there are (list of) not to list a worksheet's properties by code.  I want to make sure, I am including all properties there are in my work.  You have kind of answered my next question.

Regards,

Mike

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 11863779
Hi eghtebas,
> all properies there are
You want to list all properties of what?

Bob
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11864207
Hi Bob,

I don't see Font type in the list for example (or Font weight, Font slant, etc. to name few more).  I think, one can write some code to cycle through all excel properties and make a complete list of it.

If you are writing code like this in Excel's code window:

Cell(...).FontWeight.                       '<-- this is for illustration only.  I am not sure there is such thing as FontWeight, etc.
                           ^
                            L____________ As soon a s you type a period after FontWeight, Excel intelesense gives you two options.
                                                   These option would be Bold, and Regular (perhaps some more related options).  

Based on above example, a complete list of all property settings could be extracted by code if someone knows how to do it.  This is what I am looking for.  I hope this is a bit more clear.

Regards,

Mike
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 11864529
eghtebas,

If I understand correctly, you would start with the application and loop through each objects' collections, listing properties for each. But you should get the same information from the object browser in the ide, so I'm not sure if I understand yet. Is the code for looping through each collection, what you are after?
Bob
0
 
LVL 19

Accepted Solution

by:
Shauli earned 1200 total points
ID: 11864562
Set a reference to "TypeLib Information" (Projects > References > scrol down to TypeLib Information and check the box), and to Excel library.
Locate a listbox (list1) on your form.

'In declaration area
Dim xlsObct As Excel.Application
Dim wsObct As Worksheet

'in command1 (command button)
Private Sub Command1_Click()
    Dim TypeLib As TLI.InterfaceInfo
    Dim Prop As TLI.MemberInfo
    On Error Resume Next
    Set TypeLib = TLI.InterfaceInfoFromObject(wsObct.PageSetup)
    For Each Prop In TypeLib.Members
        Select Case Prop.InvokeKind
            Case INVOKE_PROPERTYGET
                List1.AddItem Prop.Name
        End Select
    Next

End Sub

Private Sub Form_Load()
    Set xlsObct = CreateObject("Excel.Application")
    xlsObct.Workbooks.Add
    Set wsObct = xlsObct.ActiveWorkbook.Sheets(1)
End Sub


Note: You can change the property to any of the sub properties of the worksheet, by changing this line:

Set TypeLib = TLI.InterfaceInfoFromObject(wsObct.PageSetup)
'                                                                         ^^^^^^^

S

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11865150
Hi Bob:

Re:> But you should get the same information from the object browser in the ide...

How?  How can I compile a list of all those property setting possibilties and print it on piece of paper to discuss with a client?
------------

Hi Shauli,
Now, I am raeding you post.

Regards,

Mike
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11865331
DarkoLord had answered my future question.  How to list (read) property setting of a worksheet (200).

Shauli did answer my current question (300).  Btw, Shauli's code gave me 9 more properties compared to the list from DarkoLord.
-----------------
Btw, if there is also a way to figurout how to get more properties, I would post a new question for it (in order to make it easy for future users of these fine solutions).

As part of Shauli's solution, I had a property called LeftHeader

How about list of additional properties/settings for LeftHeader:

font, font size, font slant, font color, String Value, justified(how)...

That is the ultimate thing I am looking for.
----------------
Bob,

Shauli knew I don't know much and that is why his step-by-step instrutions was so helpful.

Regards,

Mike
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 11865564
eghtebas,

Glad you got your question answered. Good Luck with your project.
Bob
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11866214
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11871653
Note:  The question in above link is deleted.  Please see:  http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21103835.html
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question