By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,966 Members | 2,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,966 IT Pros & Developers. It's quick & easy.

Problem opening Excel from VB

P: 8
I am trying to open a specific Excel speadsheet so that I can load to a table.

I am using VB6 in Citrix.

The code works OK when run locally but simply closes down the application without a runtime error when executing the exe in Citrix

The Code is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ImportID_Click()
  2. Dim S As String, RecsIn As Long, T As String, I As Long, F As Long, f1 As Long
  3. Dim iExcel As Excel.Application, iWBook As Workbook, iWSheet As Worksheet
  4. cdGetFileName.DialogTitle = "Name of Campaign File"
  5. cdGetFileName.CancelError = True
  6. cdGetFileName.FileName = ""
  7. On Error Resume Next
  8. cdGetFileName.ShowOpen
  9. If Err <> 0 Then Exit Sub
  10. Set iExcel = CreateObject("excel.application")
  11. 'ERROR CAUSED BY NEXT LINE OF CODE
  12. Set iWBook = iExcel.Application.Workbooks.Open(cdGetFileName.FileName)
  13. iWBook.Worksheets(1).Select   'Select first sheet
  14. iExcel.Range("a1").Select    'Select top left Cell
  15.  
  16. End Sub
Any help would be much appreciated
Jan 15 '08 #1
Share this Question
Share on Google+
7 Replies


Expert 5K+
P: 8,434
You still have On Error Resume Next in effect. Turn that off, and you should find out what the problem is.
Jan 16 '08 #2

P: 8
I removed the on error resume code but still did not receive a message
Jan 17 '08 #3

Expert 5K+
P: 8,434
Hm... I'm going to assume that since you mentioned Citrix you're running the program remotely on another PC.

The first things that come to mind are some sort of path problem caused by different paths on the two systems, or Excel not being available (or having some sort of configuration problem) on the remote system. Have you tried doing this while sitting at the remote PC, instead of through Citrix?
Jan 18 '08 #4

P: 8
Hm... I'm going to assume that since you mentioned Citrix you're running the program remotely on another PC.

The first things that come to mind are some sort of path problem caused by different paths on the two systems, or Excel not being available (or having some sort of configuration problem) on the remote system. Have you tried doing this while sitting at the remote PC, instead of through Citrix?
I can certainly run the application when I run it locally and not through Citrix?
Jan 24 '08 #5

P: 58
I am not familiar with Citrix, however I doubt if it knows what a workbook is.
Try changing line 3 to...
Dim iExcel As Excel.Application, iWBook As Excel.Workbook, iWSheet As Excel.Worksheet

Also in Line 12 you could eliminate the duplicate application callouts...
Set iWBook = iExcel.Workbooks.Open(cdGetFileName.Fi leName)




I can certainly run the application when I run it locally and not through Citrix?
Jan 24 '08 #6

Expert 5K+
P: 8,434
I am not familiar with Citrix, however I doubt if it knows what a workbook is...
Unless I'm mistaken (which is pretty likely) Citrix is just a remote desktop type of interface. So it shouldn't make the slightest difference to how anything runs - Windows and apps in general shouldn't know or care whether the desktop is being driven directly from the mouse/keyboard or remotely.

In which case, I wonder whether perhaps you are working under a different user account when logging on remotely, or something.
Jan 25 '08 #7

P: 8
Unless I'm mistaken (which is pretty likely) Citrix is just a remote desktop type of interface. So it shouldn't make the slightest difference to how anything runs - Windows and apps in general shouldn't know or care whether the desktop is being driven directly from the mouse/keyboard or remotely.

In which case, I wonder whether perhaps you are working under a different user account when logging on remotely, or something.
I agree that it should make any difference as to how things run.

I use the same account login etc.
Feb 1 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.