Hi I'm trying to create some sort of log system in an excel add-in im working on and so far the best way I can think of doing this is to collect event text together and then when excel attempts to close append this text to an online text file hosted on a team sharepoint. Not everyone will have the drive mapped locally so I want to ideally do this through the file URL and also not open the file as im adding the text.
So far I've managed to do this with a local file but cannot figure out how to do this with an online file through a URL. Here is what I have so far:
Sub testThis1(control As IRibbonControl)
Dim strFile_Path As String
strFile_Path = "C:/***" '<=a real address goes in here
Open strFile_Path For Append As #1
Write #1, "This Is my sample Text" & Now
Close #1
How can I go about taking this approach on a web hosted file rather than a local file? Thanks in advance for any help!
Related
I'm using MS Access 2003 for Special and old problems with the .mdb project
I want to embed my files like .txt or .exe or .pdf and run them at runtime or write that on disk.
What have I tried :
enter image description here
I don't know what's the code to do what I need I couldn't find my solution on internet.
Private Sub Form_Load()
'Me.OLEUnbound2.Application.Run
Dim obj As Object
Set obj = Me.OLEBound1.Object
'obj.DoVerb (acPrimaryVerb)
End Sub
Update:
I wrote a C# program called BMH.exe, which I open and run through Access, but I want this file to be in my source in any way possible so that the user does not have to place this file next to the program or somewhere It has Windows,
I also don't want to do things like downloading from the site, creating an installation file, I just want to access this program in any possible way through the embedded file itself, which is in the form of OLE Object and from the Packager Shell class. Write the object to a specific address or run it directly from Access itself
You can save the file as attachment in attachement field. If it will not accept an .exe file switch the extension and switch it back when exporting, you can do all this with code. Alternatively you can store the file as binary in an Ole field.
I'm starting to play around with FileStream to make a text document. When you do this, you have to clarify a path. Is there a way to create the text document in the folder the EXE file is in?
(I'm asking this because this program is meant to be downloaded, so I think I can't clarify a path specific to my computer)
Thank you!
You're right, you can't bake a path into your program that is specific to your computer because then it won't work on the user's computer
Jimi makes the wise point that often programs are installed to C:\Program Files or similar and it's not automatically possible to write to subfolders in there - you'll have to get into asking the user for permission (Elevation) .. headache
Better to decide what you want the path for:
If you need a temporary path to e.g. download something to then throw it away you can call Path.GetTempFilename() or Path.GetTempPath() - the former creates a 0 byte file with a random name in the user's temp folder, and returns the path. The latter gives you the path to the temp folder so you can create your own file
If the file is to have some permanence, such as the user saving his work, you should ask the user for it. SaveFileDialog and FolderBrowserDialog are two things you can drop on your windows form and then call ShowDialog() on to show the uer a UI where they pick a path. After they OK or Cancel, you check if they OK'd or Cancel and proceed using the dialog's Filename or SelectedPath respectively (if they OK'd)
When you're writing your files it's easier not to use FileStream unless you really need to seek in the file etc. Easier to just:
System.IO.File.WriteAllText(path here, contents here)
If you have to write the contents of a string variable to a file
The best way to create a text file, would be to use CreateText method. It will create a file besides the executable program file. You can go the following way.
Dim sw as StreamWriter = File.CreateText("myfile.txt")
Dim str as String = "Your text"
sw.Write(str)
sw.Flush()
sw.Close()
I am looking to automate a process at work, which has a step that requires me to go to a website, download data into a csv format, and then do the work and email out. I have written a set of macros that does most of this for me, however, I am having trouble understanding how to download data after navigating to the website (i see a few tutorials where the given website is already in excel format). Basically, you navigate to website, click drop-down menu, and pick export option.
I have the following script currently, and it gets me to the correct page. But I need to click on an "export" button and then an ".csv" format button once I get to this page. Does anyone have any advice, solutions or tutorials that I can look at?
'method to open chrome, collect Jira report and download it to folder
Sub getJiraReport()
Dim chromePath As String
chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""
'loads the Jira Page with report
Shell (chromePath & " -url https://companyname.atlassian.net/issues/? filter=10600")
End Sub
So, how can I tell the system to open the file for me? I've tried
Shell(ExcelFilePath)
But an exception was thrown although the file path is from OpenFileDialog.FileOk
So, I am trying to play with Excel.Application, is it possible to open the file with that?
This will open the file with Excel:
Process.Start("EXCEL.EXE", """C:\Folder\file.xls""")
Being the second string the arguments for the process. See the MSDN Dcoumentation.
try this
System.Diagnostics.Process.Start("FilePath")
it will open the file in an application associated with it.
I need to generate PDFs from word files regularly, and I'm getting tired of doing it by hand.
Manually, all I do is open a file, and click "Save as PDF". So, one would think applescript would be a nice easy way to do this. [If you have another approach than applescript, I'm open to it.]
I'm almost there, the following script works, except the full path is hard coded.
tell application "Microsoft Word"
open file "Macintosh HD:Users:me:repos:training:class:Activities:ActivityGuide.docx"
set doc to document "ActivityGuide.docx"
save as doc file name "Macintosh HD:Users:me:repos:training:class:Activities:ActivityGuide.pdf" file format format PDF
end tell
I need it to work for other people, on other machines, so the username and other parts of the path may change. If I could just do this from the current directory for the script, I'd be set.
I found this: Applescript to launch file from current folder?
tell application "Finder"
open file "somefile.txt" of folder of (file (path to me))
end tell
Which works for opening an app from the current directory in Word, via Finder, but I think I need to open it with an application of "Microsoft Word", if I'm going to use "Save As". But this method of opening doesn't work if I change the application for "Finder" to "Microsoft Word".
Any suggestions welcome.
[edit: clarity]
Try this
set x to path to me
tell application "Finder" to set tFile to (file "ActivityGuide.docx" of (container of x)) as alias
set newFile to (text 1 thru -5 of (tFile as string)) & "pdf"
tell application "Microsoft Word"
open tFile
tell document 1
save as file name newFile file format format PDF
close saving no
end tell
end tell
Another thing that might be helpful to you is under System Preferences:Keyboard:Shortcuts: App Shortcuts:All Applications
Make a shortcut that is named "Save as PDF..." assign the shortcut to command+P since most applications that is the shortcut for print, then just press it twice and it will prompt you to save it as a PDF (I got that tip from David Sparks) and depending on the application it will default to where the file was opened up from. You can also set that with the application Default Folder X.
Hopefully that is a bit more of a global solution for other problems but it looks like you already have the answer to this isolated problem.