|
-
Dec 2nd, 2004, 06:02 AM
#1
Thread Starter
Junior Member
Changing Excell Height and Width
Hiiiii,
I am opening an Excell file using Excell object Library.
Dim xlTmp As Excel.Application
Dim sparth As String
Dim formwidth As Double
Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open File1.Path & "\" & sparth,
xlTmp.Left = 20000
Set xlTmp.Width = 774
xlTmp.Height = 561 'Screen.Height - 5000
xlTmp.Width = 553
xlTmp.Visible = True
But when I am trying to set the Height and the Width of the Excel file it give the following error...
Runtime Error
"Method Height of object Application failed"
I need to change the Height and width of the opend excell file at run time......
Can anyone help me on this....
Thanks
Sam
-
Dec 2nd, 2004, 06:26 AM
#2
At a guess, I cant test this theory out at the moment; however, I think
you may need to include a worksheet object, and Set that to the existing xlTmp.
What you are trying to do is adjust the application width/height, and you need to be adjusting the Worksheet width/height.
Bruce.
-
Dec 2nd, 2004, 07:56 AM
#3
Thread Starter
Junior Member
Hiii,
I tired it But there's no property to set the worksheet Height and width......
Sam
-
Dec 2nd, 2004, 12:19 PM
#4
In order to change any height/width props of the main window, it
needs to be in a windowstate of Normal, not maximized or
minimized. This will work.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim xlTmp As Excel.Application
Dim sparth As String
Dim formwidth As Double
Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open "D:\My Documents\Book1.xls"
[b][color=red]xlTmp.WindowState = xlNormal[/color][/b]
xlTmp.Left = 20000
xlTmp.Width = 774
xlTmp.Height = 561 'Screen.Height - 5000
xlTmp.Width = 553
xlTmp.Visible = True
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 
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
|