-
Jun 2nd, 2014, 07:44 AM
#1
Thread Starter
Addicted Member
[RESOLVED] What is wrong in this expression
Hi
I have a excel sheet there I will copy a cell d:58 to a label17
tried serveral suggestions on internet but I can't get it to work
Code:
Dim objXl As New Excel.Application
Dim objWb As Excel.Workbook
Dim xlTmp As Excel.Application
Set xlTmp = Excel.Application
If File3.FileName = Left$(File3.FileName, 4) Then
File3.FileName = File3.FileName
End If
Dim AppExcel As Object
Set AppExcel = CreateObject("Excel.application")
AppExcel.Workbooks.open Dir2.Path + "\kundfaktura\" + File3.FileName
AppExcel.Visible = True
Label17.Caption = objWb.Worksheets("blad1").Range("D58").Value ' runtime error 91
Help please
-
Jun 2nd, 2014, 08:02 AM
#2
Re: What is wrong in this expression
Your if statement does not make sense, it should be removed. When you want to add a string to a string do no use + use & instead. Does your file load into your excel sheet?
-
Jun 2nd, 2014, 08:37 AM
#3
Frenzied Member
Re: What is wrong in this expression
if you have already declared
Code:
Dim objXl As New Excel.Application
then again declaring xlTmp as excel.application is also does not make sense . please read basic things like variable , object and how to work on excel .google it .and you will get more detail and idea .and then come back here .
-
Jun 2nd, 2014, 08:38 AM
#4
Re: What is wrong in this expression
Also, to fix your '91' problem, try this:
Code:
Dim AppExcel As Excel.Application
Dim objWb As Excel.workbook
Set AppExcel = CreateObject("Excel.Application")
Set objWb = AppExcel.Workbooks.Add
Set objWb = GetObject(Dir2.Path & "\kundfaktura\" & file3.FileName)
Label17.Caption = objWb.Worksheets("blad1").Range("D58").Value
-
Jun 2nd, 2014, 09:06 AM
#5
Thread Starter
Addicted Member
Re: What is wrong in this expression
Originally Posted by SamOscarBrown
Also, to fix your '91' problem, try this:
Code:
Dim AppExcel As Excel.Application
Dim objWb As Excel.workbook
Set AppExcel = CreateObject("Excel.Application")
Set objWb = AppExcel.Workbooks.Add
Set objWb = GetObject(Dir2.Path & "\kundfaktura\" & file3.FileName)
Label17.Caption = objWb.Worksheets("blad1").Range("D58").Value
THANKS very much it realy works
-
Jun 2nd, 2014, 09:11 AM
#6
Re: What is wrong in this expression
Now, try to figure out WHY. :-) Compare that with yours.
-
Jun 2nd, 2014, 09:26 AM
#7
Thread Starter
Addicted Member
Re: What is wrong in this expression
Okej I whas in little hurry
but after I gone true the code I changed a line
Dim AppExcel As Excel.Application
Dim objWb As Excel.workbook
Set AppExcel = CreateObject("Excel.Application")
Set objWb = AppExcel.Workbooks.Add
'''''''''''''********* 'Set objWb = GetObject(Dir2.Path & "\kundfaktura\" & file3.FileName)
Set objWb = Workbooks.open(Dir2.Path & "\kundfaktura\" & File3.FileName)
Label17.Caption = objWb.Worksheets("blad1").Range("D58").Value
then it's works fine all time
THANKS
Last edited by Bonzo2008; Jun 2nd, 2014 at 09:38 AM.
-
Jun 2nd, 2014, 10:19 AM
#8
Re: What is wrong in this expression
NP----please mark this thread as Resolved (Thread Tools menu)
-
Jun 2nd, 2014, 10:21 AM
#9
Thread Starter
Addicted Member
Re: What is wrong in this expression
HI again
a little problem
when I have collect say file one then a msg box
saying Microsft Excel
will you save changes to file with number 2222.xls
how can I get rid of this in the file3_dblclick
-
Jun 2nd, 2014, 10:25 AM
#10
Re: What is wrong in this expression
Can you mark this thread as Resolved? Then open a NEW thread with a topic more suited to your NEW problem? Also, it would be of TREMENDOUS value if you could attach your project (or at least the applicable code that does not work)?
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
|