Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-15
3
Medium Priority
?
287 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 53

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

916 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