1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VBScriptについて

Last updated at Posted at 2019-05-16

VBSでEXCELマクロ実行

pushd E:\test
RunMacro.vbs マクロ.xlsm

--
RunMacro.vbs (macro1はEXCELマクロの名前)

Dim BookPath
Dim FS, Folder
Dim Excel, Book, Sheet

main

If Err.Number = 0 Then
	WScript.Quit(0)
Else
	MsgBox Err.Description

	If IsNull(Excel) Then
		Excel.Quit
	End If

	WScript.Quit(1)
End If

Sub main()

	BookPath = WScript.Arguments(0)

	Set FS = WScript.CreateObject("Scripting.FileSystemObject")
	Set Folder = FS.GetFolder(".")

	If Mid(BookPath, 1, 1) <> "\" And Mid(BookPath, 2, 1) <> ":" Then
 		BookPath = Folder.path + "\" + BookPath
	End If

	Set Excel = WScript.CreateObject("Excel.Application")

	Excel.Visible = False
	Excel.DisplayAlerts = False

	Excel.Workbooks.Open BookPath

	Set Book = Excel.Workbooks(1)
	Set Sheet = Book.Sheets(1)

	Excel.Run "macro1"
	'①②③はどちらでもマクロファイルを保存なしで終了する
	'Book.Saved=true
	'②
	'Book.Close False 
	'③
	Excel.DisplayAlerts = False 
	'マクロファイルを保存して終了する
	'Book.Save
	'Book.Close
	Excel.Quit

End Sub

VBSでIEを開く


 Set objIE = CreateObject("InternetExplorer.Application")
 objIE.Visible = True

 objIE.FullScreen = False
 objIE.Top = 100
 objIE.Left = 1480
 objIE.Width = 430
 objIE.Height = 150

 objIE.Toolbar = False
 objIE.MenuBar = False
 objIE.AddressBar = False
 objIE.StatusBar = False

 objIE.Navigate2 "http://server/solar/default.asp"

 Set WSHShell = WScript.CreateObject("WScript.Shell")
 WSHShell.AppActivate "Explorer"
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?