1,075,613 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by johndmingione

Dear Reader,

I would like to be educated on how to open an Excel Worksheet within a VSFlexGrid OR MSFlexGrid. The reason I give both as an option is because I want to explore which option is best, so if you have input on the Pros and Cons of using either and which I should use, please give it

Anyways, I know how to open one up within the VSFlexGrid. However, the reason I'm asking this Forum is because I want this VSFlexGrid to open a Worksheet according to what the other one opened previously. So let me explain:

The original Form opens a Worksheet per whatever the User wants. Meaning, he or she can open Worksheets with a certain format. Let's call this worksheet that the User theoretically opens, WorksheetRandom.xls. So the User opens up WorksheetRandom.xls and within it is an entire Workbook. However, the VSFlexGrid on my Home Form has a Worksheet called Report. The VSFlexGrid pulls from that specific Worksheet and populates the VSFlexGrid according to the specific Columns within that Worksheet. SO...what I would like to do is essentially take that same Workbook that they ALREADY CHOSE and take a different Worksheet than the original Home Form pulls and display it on a different VS or MSFlexGrid on a different form.

If I left out any information please let me know. Otherwise, if someone can tell me how to get started it would be greatly appreciated.

--

So I began messing around with the code and just put a very basic version of it trying to open up Excel. Here's the code, tell me if I'm missing something, again it's very basic:

Code:

Option Explicit

Dim exApp As Object
Dim exBook As Object
Dim exSheet As Object

Private Sub Form_Activate()

Set exApp = CreateObject("Excel.Application")
Set exBook = exApp.Workbooks.Open(strROBlitZFilePath)
Set exSheet = exBook.Worksheet("Report")

'Code Goes Here :)

Set exSheet = Nothing
Set exBook = Nothing
Set exApp = Nothing

End Sub

strROBlitzFilePath is already Dim'd as a String
And assigned value as the Worksheet that the User chooses which is exactly what I'm looking for. There is an error message that pops up however. Labeled as error 1004. Attached is an image of the error. So you can take a look. If anyone can continue to help me out from here it would be greatly appreciated. I'm going to try and keep plugging away at this on my own.

Untitled81

Attachments Untitled.png 22.72KB
johndmingione
Newbie Poster
2 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

I'm having some trouble defining constants correctly.

I know the format should be this:

Const CONSTANT_NAME [As ConstantType] = value

But I'm a little unclear of how to word it. So here is the Line I need to change into a Constant. Normally I would have a BAS file do this but I can't find one (Refer to other post).

Code:

With oXLSheet.Range("A1:A10")
        .Font.ColorIndex = 50
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
End With

That's the entire section that I'm dealing with. I don't think all of it needs to be constants, but maybe it does? I'm not sure. All I know is that the tutorial helping me with creating automation suggested that I turn my Code into Late-Bound to help with compatibility issues a User might have in regards to opening Excel. As a result, I have had to drop the Excel Reference that I was using therefore, having to define my own constants. As stated previous, here and in the other Thread, I wanted to make it easier by Inserting a BAS File into a Module as suggested and provided by the Tutorial I'm using but there were x64 bit compatibility issues with that so I couldn't. If anyone could help me turn the "xlCenter" part into a Constant it would be greatly appreciated. I am very new at this and still learning so I thank you for your patience.

Thank you for taking the time to read this

johndmingione
Newbie Poster
2 posts since May 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.0404 seconds using 2.47MB