|
-
Nov 11th, 2008, 01:53 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] AddPicture from Application.StartupPath
Hi
This is maybe very simple, but need some advice on the path. In my app I add a picture to a excel sheet, and it's working fine but I don't want the file in ex. c:. It should be in the Application.StartupPath, therefore I used this:
Code:
xlWorkSheet.Shapes.AddPicture(Application.StartupPath, & "\Test.JPG", _
Microsoft.Office.Core.MsoTriState.msoFalse, _
Microsoft.Office.Core.MsoTriState.msoCTrue, 2, 2, 30, 30)
but with this I get "expression expected" with the &. If I use a path "c:\Test.jpg", it work's.
-
Nov 11th, 2008, 02:03 AM
#2
Re: AddPicture from Application.StartupPath
You have a comma after Application.StartupPath
-
Nov 11th, 2008, 03:13 AM
#3
Thread Starter
Hyperactive Member
Re: AddPicture from Application.StartupPath
Hi
Thank's. But now I get file is a none shared member. Requires an object reference.
-
Nov 11th, 2008, 06:19 AM
#4
Thread Starter
Hyperactive Member
Re: AddPicture from Application.StartupPath
I'm sure there's a better way of doing this, but this seams to work.
Code:
Private Function AppPath() As String
Return System.Windows.Forms.Application.StartupPath
End Function
xlWorkSheet.Shapes.AddPicture(AppPath & "\Test.JPG", _
Microsoft.Office.Core.MsoTriState.msoFalse, _
Microsoft.Office.Core.MsoTriState.msoCTrue, 2, 2, 30, 30)
-
Nov 11th, 2008, 11:16 AM
#5
Re: [RESOLVED] AddPicture from Application.StartupPath
if that works there is no reason why this shouldn't work
Code:
xlWorkSheet.Shapes.AddPicture(System.Windows.Forms.Application.StartupPath & "\Test.JPG", _
Microsoft.Office.Core.MsoTriState.msoFalse, _
Microsoft.Office.Core.MsoTriState.msoCTrue, 2, 2, 30, 30)
-
Nov 11th, 2008, 02:59 PM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED] AddPicture from Application.StartupPath
Absolute true. If anyone is lazy, they don't have to type the whole string over and over again. Like me
-
Nov 11th, 2008, 03:11 PM
#7
Re: [RESOLVED] AddPicture from Application.StartupPath
well if this code is in a project that has a project level import of system.windows.forms (like winform apps do by default), you shouldn't have to qualify it with System.Windows.Forms, you can just call application.startuppath.
If this code is not in a project that has system.windows.forms as a project level imports, you could add it, or you could just add an imports statement to the top of the code module, and then you would be able to use just application.startuppath there as well.
If you are writing
-
Nov 11th, 2008, 05:15 PM
#8
Thread Starter
Hyperactive Member
Re: [RESOLVED] AddPicture from Application.StartupPath
Of course you're right, but since I'm a self learning "programmer" fundamental things is sometimes overseen. My solutions of problems is quite often trial and error. Learning by doing. Thank's for taking your time.
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
|