Solved

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

Posted on 2013-01-15
3
230 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 48

Expert Comment

by:Rgonzo1971
Comment Utility
0
 

Accepted Solution

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

Author Closing Comment

by:fjkilken
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
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…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

7 Experts available now in Live!

Get 1:1 Help Now