|
-
Feb 6th, 2005, 05:32 AM
#1
Thread Starter
New Member
Get excel formatting information
I'm using vb6 to extract data from an excel worksheet. Is there any way to obtain formatting information? I need individual column widths and whether text spans a number of columns.
-
Feb 6th, 2005, 01:08 PM
#2
Re: Get excel formatting information
Since there are a few questions to be answered I think this way is best.
Usually the easiest way to find out how to access some property or method in most Office Apps is to record
a macro and then check out the code in the VBA IDE (ALT+F11). Its usually in a Module with the date it was written in the
header of the procedure. Then you can place the code in VB with a little translating where needed.
Post back if you neeed more help on this.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 7th, 2005, 04:06 AM
#3
Thread Starter
New Member
Re: Get excel formatting information
Yes, I agree but, in this case, I can't see how to record a macro asking for the information I need.
-
Feb 7th, 2005, 11:49 AM
#4
Re: Get excel formatting information
Ok, here is the first recorded macro. I just started a recording and adjusted a column's width.
VB Code:
Sub Macro1()
' Macro1 Macro
' Macro recorded 2/7/2005 by VB/Office Guru
Columns("C:C").ColumnWidth = 20
Columns("E:E").ColumnWidth = 6
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 7th, 2005, 11:56 AM
#5
Re: Get excel formatting information
Ok, now this one is a little different. I had to go into the Formatting menu
and click Cells... then check Merge cells after I selected three cells that I
had typed some text into. I typed the text into the first cell and continued
typing until it reached the third cell.
VB Code:
Sub Macro2()
' Macro2 Macro
' Macro recorded 2/7/2005 by VB/Office Guru
Range("A4").Select
ActiveCell.FormulaR1C1 = "Testing the macro to record spaned cell info."
Range("A4:C4").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
End Sub
So these two macros will show you how to access the properties/methods
to determine the formatting on a spreadsheet.

HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 8th, 2005, 04:45 AM
#6
Thread Starter
New Member
Re: Get excel formatting information
THanks very much for taking so much trouble to help me. I'll get working along these lines.
-
Feb 8th, 2005, 12:01 PM
#7
Re: Get excel formatting information
Not a problem. Glad to help. 
Ps, dont forget to Resolve your thread
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|