Solved

Need to open text file for use in Excel Backstage/Ribbon component

Posted on 2013-01-15
3
243 Views
Last Modified: 2013-01-29
Hi
I am looking to assign dynamic text to the label property a labelControl object in a custom Backstage/Ribbon project(in Excel), this text needs to come from an external text file.

I am looking for a method similar to the one which currently works when I want to reference an image file per below:

Sub getImage(control As IRibbonControl, index As Integer, ByRef image)
Set image = LoadPicture("c:\temp\image1.jpg")
End Sub

The labelControl object has a callback property (getLabel), which I intend to use in order to feed the text from the external text file to it.

So something like:

Sub getExternalText(control As IRibbonControl, ByRef textfile)
Set textfile= LoadFile("c:\temp\test.text")
End Sub

..would be great if it worked.

Appreciate any suggestions

Thanks a lot
Fergal
0
Comment
Question by:fjkilken
  • 2
3 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 38778005
0
 

Accepted Solution

by:
fjkilken earned 0 total points
ID: 38814908
I have now found a solution to the issue - thanks.
0
 

Author Closing Comment

by:fjkilken
ID: 38830308
Sub importTextFile(control As IRibbonControl, ByRef labeltext)
Dim fname As String
Dim sVal As String
fname = "C:\temp\Test.txt"
labeltext = OpenTextFileToString(fname)
'Debug.Print sVal
'MsgBox sVal
End Sub

Function OpenTextFileToString(ByVal strFile As String) As String
Dim hFile As Long
hFile = FreeFile
Open strFile For Input As #hFile
OpenTextFileToString = Input$(LOF(hFile), hFile)
Close #hFile
End Function
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multi-user Excel not reflecting who actually has the file opened 10 30
Generating a graph via Excel 3 26
Macro 6 50
Excel case statements 3 24
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now